Skip to content

Commit

Permalink
add short flag
Browse files Browse the repository at this point in the history
  • Loading branch information
c-pius committed Oct 21, 2024
1 parent 5450a32 commit ac207c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/modulectl/scaffold/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ func Test_Execute_ParsesOptions(t *testing.T) {

func Test_Execute_ParsesShortOptions(t *testing.T) {
directory := testutils.RandomName(10)
configFile := testutils.RandomName(10)
os.Args = []string{
"scaffold",
"-c", configFile,
"-d", directory,
"-o",
}
Expand All @@ -95,6 +97,7 @@ func Test_Execute_ParsesShortOptions(t *testing.T) {
err := cmd.Execute()
require.NoError(t, err)

assert.Equal(t, configFile, svc.opts.ModuleConfigFileName)
assert.Equal(t, directory, svc.opts.Directory)
assert.True(t, svc.opts.ModuleConfigFileOverwrite)
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/modulectl/scaffold/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
directoryFlagUsage = `Specifies the target directory where the scaffolding shall be generated (default "./").`

ModuleConfigFileFlagName = "config-file"
moduleConfigFileFlagShort = "c"
ModuleConfigFileFlagDefault = "scaffold-module-config.yaml"
moduleConfigFileFlagUsage = `Specifies the name of the generated module configuration file (default "scaffold-module-config.yaml").`

Expand Down Expand Up @@ -50,7 +51,7 @@ const (

func parseFlags(flags *pflag.FlagSet, opts *scaffold.Options) {
flags.StringVarP(&opts.Directory, DirectoryFlagName, directoryFlagShort, DirectoryFlagDefault, directoryFlagUsage)
flags.StringVar(&opts.ModuleConfigFileName, ModuleConfigFileFlagName, ModuleConfigFileFlagDefault, moduleConfigFileFlagUsage)
flags.StringVarP(&opts.ModuleConfigFileName, ModuleConfigFileFlagName, moduleConfigFileFlagShort, ModuleConfigFileFlagDefault, moduleConfigFileFlagUsage)
flags.BoolVarP(&opts.ModuleConfigFileOverwrite, ModuleConfigFileOverwriteFlagName, moduleConfigFileOverwriteFlagShort, ModuleConfigFileOverwriteFlagDefault, moduleConfigFileOverwriteFlagUsage)
flags.StringVar(&opts.ManifestFileName, ManifestFileFlagName, ManifestFileFlagDefault, manifestFileFlagUsage)
flags.StringVar(&opts.DefaultCRFileName, DefaultCRFlagName, DefaultCRFlagDefault, defaultCRFlagUsage)
Expand Down
2 changes: 1 addition & 1 deletion docs/gen-docs/modulectl_scaffold.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ Generate a scaffold with a manifest file, default CR and security-scanners confi
## Flags

```bash
-c, --config-file string Specifies the name of the generated module configuration file (default "scaffold-module-config.yaml").
-d, --directory string Specifies the target directory where the scaffolding shall be generated (default "./").
--gen-default-cr string Specifies the default CR in the generated module config. A blank default CR file is generated if it doesn't exist (default "default-cr.yaml").
--gen-manifest string Specifies the manifest in the generated module config. A blank manifest file is generated if it doesn't exist (default "manifest.yaml").
--gen-security-config string Specifies the security file in the generated module config. A scaffold security config file is generated if it doesn't exist (default "sec-scanners-config.yaml").
-h, --help Provides help for the scaffold command.
--module-channel string Specifies the module channel in the generated module config file (default "regular").
--config-file string Specifies the name of the generated module configuration file (default "scaffold-module-config.yaml").
--module-name string Specifies the module name in the generated config file (default "kyma-project.io/module/mymodule").
--module-version string Specifies the module version in the generated module config file (default "0.0.1").
-o, --overwrite Specifies if the command overwrites an existing module configuration file.
Expand Down

0 comments on commit ac207c4

Please sign in to comment.