Skip to content

Commit

Permalink
Merge pull request #21 from Peefy/format-cli-documents
Browse files Browse the repository at this point in the history
chore: format all command documents
  • Loading branch information
Peefy authored Nov 30, 2023
2 parents badad1b + 2667cad commit d390787
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 116 deletions.
6 changes: 2 additions & 4 deletions cmd/kcl/commands/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ import (
)

const (
cleanDesc = `
This command cleans the kcl build cache.
cleanDesc = `This command cleans the kcl build cache.
`
cleanExample = ` # Clean the build cache
kcl clean
`
kcl clean`
)

// NewCleanCmd returns the clean command.
Expand Down
20 changes: 4 additions & 16 deletions cmd/kcl/commands/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,12 @@ import (
)

const (
docDesc = `
This command shows documentation for KCL package or symbol.
docDesc = `This command shows documentation for KCL modules or symbols.
`
docExample = ` # Generate document for current package
kcl doc generate
`
docGenDesc = ` # Generate Markdown document for current package
kcl doc generate
# Generate Html document for current package
kcl doc generate --format html
kcl doc generate`

# Generate Markdown document for specific package
kcl doc generate --file-path <package path>
# Generate Markdown document for specific package to a <target directory>
kcl doc generate --file-path <package path> --target <target directory>
docGenDesc = `This command generates documents for KCL modules.
`
docGenExample = ` # Generate Markdown document for current package
kcl doc generate
Expand All @@ -38,8 +27,7 @@ This command shows documentation for KCL package or symbol.
kcl doc generate --file-path <package path>
# Generate Markdown document for specific package to a <target directory>
kcl doc generate --file-path <package path> --target <target directory>
`
kcl doc generate --file-path <package path> --target <target directory>`
)

// NewDocCmd returns the doc command.
Expand Down
3 changes: 1 addition & 2 deletions cmd/kcl/commands/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import (
)

const (
fmtDesc = `
This command formats all kcl files of the current crate.
fmtDesc = `This command formats all kcl files of the current crate.
`
fmtExample = ` # Format the single file
kcl fmt /path/to/file.k
Expand Down
6 changes: 2 additions & 4 deletions cmd/kcl/commands/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
)

const (
importDesc = `
This command converts other formats to KCL file.
importDesc = `This command converts other formats to KCL file.
Supported conversion modes:
- json: convert JSON data to KCL data
Expand Down Expand Up @@ -40,8 +39,7 @@ Supported conversion modes:
kcl import -m terraformschema schema.json
# Generate KCL models from Go structs
kcl import -m gostruct schema.go
`
kcl import -m gostruct schema.go`
)

// NewImportCmd returns the import command.
Expand Down
6 changes: 2 additions & 4 deletions cmd/kcl/commands/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
)

const (
lintDesc = `
This command lints the kcl code. 'kcl lint' takes multiple input for arguments.
lintDesc = `This command lints the kcl code. 'kcl lint' takes multiple input for arguments.
For example, 'kcl lint path/to/kcl.k' will lint the file named path/to/kcl.k
`
Expand All @@ -23,8 +22,7 @@ For example, 'kcl lint path/to/kcl.k' will lint the file named path/to/kcl.k
kcl lint oci://ghcr.io/kcl-lang/hello-world
# Lint the current package
kcl lint
`
kcl lint`
)

// NewLintCmd returns the lint command.
Expand Down
3 changes: 1 addition & 2 deletions cmd/kcl/commands/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
)

const (
modDesc = `
This command manages the kcl module
modDesc = `This command manages the kcl module
`
modExample = ` kcl mod <command> [arguments]...
# Init one kcl module
Expand Down
17 changes: 8 additions & 9 deletions cmd/kcl/commands/mod_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ import (
)

const (
modAddDesc = `
This command adds new dependency
`
modAddDesc = `This command adds new dependency
`
modAddExample = ` # Add the module dependency named "k8s"
kcl mod add k8s
# Add the module dependency named "k8s" with the version "1.28"
kcl mod add k8s:1.28
kcl mod add k8s
# Add the module dependency named "k8s" with the version "1.28"
kcl mod add k8s:1.28
# Add a local dependency
kcl mod add /path/to/another_module`
# Add a local dependency
kcl mod add /path/to/another_module`
)

// NewModAddCmd returns the mod add command.
Expand Down
13 changes: 6 additions & 7 deletions cmd/kcl/commands/mod_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ import (
)

const (
modInitDesc = `
This command initializes new kcl module in current directory.
`
modInitDesc = `This command initializes new kcl module in current directory.
`
modInitExample = ` kcl mod init <command> [arguments]...
# Init one kcl module with the current folder name
kcl mod init
# Init one kcl module with the current folder name
kcl mod init
# Init one kcl module with the name
kcl mod init package-name`
# Init one kcl module with the name
kcl mod init package-name`
)

// NewModInitCmd returns the mod init command.
Expand Down
15 changes: 7 additions & 8 deletions cmd/kcl/commands/mod_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ import (
)

const (
modMetadataDesc = `
This command outputs the resolved dependencies of a package
`
modMetadataDesc = `This command outputs the resolved dependencies of a package
`
modMetadataExample = ` # Output the resolved dependencies the current module
kcl mod metadata
kcl mod metadata
# Output the resolved dependencies the current module in the vendor mode
kcl mod metadata --vendor
# Output the resolved dependencies the current module in the vendor mode
kcl mod metadata --vendor
# Output the resolved dependencies the current module with the update check
kcl mod metadata --update`
# Output the resolved dependencies the current module with the update check
kcl mod metadata --update`
)

// NewModMetadataCmd returns the mod metadata command.
Expand Down
15 changes: 7 additions & 8 deletions cmd/kcl/commands/mod_pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ import (
)

const (
modPkgDesc = `
This command converts a kcl module into tar
`
modPkgDesc = `This command converts a kcl module into tar
`
modPkgExample = ` # Package the current module
kcl mod pkg
kcl mod pkg
# Package the current module in the vendor mode
kcl mod pkg --vendor
# Package the current module in the vendor mode
kcl mod pkg --vendor
# Package the current module into the target directory
kcl mod pkg --target /path/to/target_dir`
# Package the current module into the target directory
kcl mod pkg --target /path/to/target_dir`
)

// NewModPkgCmd returns the mod pkg command.
Expand Down
7 changes: 3 additions & 4 deletions cmd/kcl/commands/mod_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import (
)

const (
modPullDesc = `
This command pulls kcl modules from the registry.
`
modPullDesc = `This command pulls kcl modules from the registry.
`
modPullExample = ` # Pull the the module named "k8s" to the local path from the registry
kcl mod pull k8s`
kcl mod pull k8s`
)

// NewModPullCmd returns the mod pull command.
Expand Down
11 changes: 5 additions & 6 deletions cmd/kcl/commands/mod_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ import (
)

const (
modPushDesc = `
This command pushes kcl modules to the registry.
`
modPushDesc = `This command pushes kcl modules to the registry.
`
modPushExample = ` # Push the current module to the registry
kcl mod push
kcl mod push
# Push the current module to the registry in the vendor mode
kcl mod push --vendor`
# Push the current module to the registry in the vendor mode
kcl mod push --vendor`
)

// NewModPushCmd returns the mod push command.
Expand Down
11 changes: 5 additions & 6 deletions cmd/kcl/commands/mod_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ import (
)

const (
modUpdateDesc = `
This command updates dependencies listed in kcl.mod.lock based on kcl.mod.
`
modUpdateDesc = `This command updates dependencies listed in kcl.mod.lock based on kcl.mod.
`
modUpdateExample = ` # Update the current module
kcl mod update
kcl mod update
# Update the module with the specified path
kcl mod update path/to/package`
# Update the module with the specified path
kcl mod update path/to/package`
)

// NewModUpdateCmd returns the mod update command.
Expand Down
3 changes: 1 addition & 2 deletions cmd/kcl/commands/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import (
)

const (
playDesc = `
This command opens the kcl playground in the browser.
playDesc = `This command opens the kcl playground in the browser.
`
playExample = ` # Open in the localhost:80 and open the browser.
kcl play --open
Expand Down
6 changes: 2 additions & 4 deletions cmd/kcl/commands/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import (
)

const (
registryDesc = `
This command manages the kcl registry
registryDesc = `This command manages the kcl registry
`
registryExample = ` # Login the registry
kcl registry login docker.io
# Logout the registry
kcl registry logout
`
kcl registry logout`
)

var (
Expand Down
17 changes: 8 additions & 9 deletions cmd/kcl/commands/registry_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ import (
)

const (
registryLoginDesc = `
This command can be used to login to a registry.
`
registryLoginDesc = `This command can be used to login to a registry.
`
registryLoginExample = ` # Login the docker hub
kcl registry login docker.io
kcl registry login docker.io
# Login the GitHub container registry
kcl registry login ghcr.io
# Login the GitHub container registry
kcl registry login ghcr.io
# Login a localhost registry
kcl registry login https://localhost:5001
`
# Login a localhost registry
kcl registry login https://localhost:5001
`
)

// NewRegistryLoginCmd returns the registry login command.
Expand Down
9 changes: 4 additions & 5 deletions cmd/kcl/commands/registry_logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import (
)

const (
registryLogoutDesc = `
This command can be used to logout from the current registry.
`
registryLogoutDesc = `This command can be used to logout from the current registry.
`
registryLogoutExample = ` # Logout the registry
kcl registry logout docker.io
`
kcl registry logout docker.io
`
)

// NewRegistryLogoutCmd returns the registry logout command.
Expand Down
6 changes: 2 additions & 4 deletions cmd/kcl/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
)

const (
runDesc = `
This command runs the kcl code and displays the output. 'kcl run' takes multiple input for arguments.
runDesc = `This command runs the kcl code and displays the output. 'kcl run' takes multiple input for arguments.
For example, 'kcl run path/to/kcl.k' will run the file named path/to/kcl.k
`
Expand All @@ -26,8 +25,7 @@ For example, 'kcl run path/to/kcl.k' will run the file named path/to/kcl.k
kcl run oci://ghcr.io/kcl-lang/hello-world
# Run the current package
kcl run
`
kcl run`
)

// NewRunCmd returns the run command.
Expand Down
6 changes: 2 additions & 4 deletions cmd/kcl/commands/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
)

const (
serverDesc = `
This command runs a kcl server with multiple REST APIs. See https://kcl-lang.io/docs/reference/xlang-api/rest-api for more information.
serverDesc = `This command runs a kcl server with multiple REST APIs. See https://kcl-lang.io/docs/reference/xlang-api/rest-api for more information.
`
serverExample = ` # Run a kcl server
kcl server
Expand All @@ -22,8 +21,7 @@ This command runs a kcl server with multiple REST APIs. See https://kcl-lang.io/
curl -X POST http://127.0.0.1:2021/api:protorpc/BuiltinService.ListMethod --data '{}'
# Use the Run API
curl -X POST http://127.0.0.1:2021/api:protorpc/KclvmService.ExecProgram -H "accept: application/json" --data '{"k_filename_list": ["main.k"]}'
`
curl -X POST http://127.0.0.1:2021/api:protorpc/KclvmService.ExecProgram -H "accept: application/json" --data '{"k_filename_list": ["main.k"]}'`
)

var (
Expand Down
6 changes: 2 additions & 4 deletions cmd/kcl/commands/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import (
)

const (
testDesc = `
This command automates testing the packages named by the import paths.
testDesc = `This command automates testing the packages named by the import paths.
'KCL test' re-compiles each package along with any files with names matching
the file pattern "*_test.k". These additional files can contain test functions
Expand All @@ -29,8 +28,7 @@ that starts with "test_*".
kcl test ./... --fail-fast
# Test with the regex expression filter 'test_func'
kcl test ./... --run test_func
`
kcl test ./... --run test_func`
)

// NewTestCmd returns the test command.
Expand Down
Loading

0 comments on commit d390787

Please sign in to comment.