Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support command selection with the config command #22

Merged
merged 2 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,10 @@ regardless of the previous license header.

- **Flags**

| Short | Long | Default | Description |
|-------|-------------|------------------------------------|-----------------|
| -h | --help | null | help for config |
| Short | Long | Default | Description |
|-------|-------------|------------------------------------|--------------------|
| -c | --command | add | command to execute |
| -h | --help | null | help for config |

**NOTE: If some configuration are not configured, the default configuration will be used.**

Expand Down
7 changes: 4 additions & 3 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ var configCmd = &cobra.Command{
Use: "config",
Short: "edit the files according to the configuration file",
Long: `Config Command | Edit files according to the configuration file
EXAMPLE: nwa config config.yaml
NOTE: This command does not have any flag;
EXAMPLE: nwa config config.yaml -c check
NOTE: This command only supports the command flag;
You can only specify the path of the configuration file, and everything depends on the configuration file;
If some configuration are not configured, the default configuration will be used
If some configuration are not configured, the default configuration will be used;
The command can be set on the command line
SAMPLE CONFIGURATION FILE(YAML):
nwa:
cmd: "add"
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func setupCommonCmd(common *cobra.Command) {
}

func setupConfigCmd(config *cobra.Command) {
config.Flags().StringVarP(&defaultConfig.Nwa.Cmd, "command", "c", defaultConfig.Nwa.Cmd, "command")
rootCmd.AddCommand(config)
}

Expand Down
Loading