Skip to content

Commit 9366c4a

Browse files
Pass individual snowblock paths as arguments instead of flag values
To simplify the CLI usage and removing the requirement to pass correctly formatted (comma-separated) values to the `--snowblocks`/`-s` flag (1) to process individual snowblocks the `bootstrap` command now accepts one or more space-separated snowblock directory paths. References: (1) https://github.com/arcticicestudio/snowsaw/blob/145a4c36caf960fc9a43b16c105df997e819a04d/cmd/snowsaw/bootstrap/bootstrap.go#L46 Epic: GH-33 Resolves GH-78
1 parent ed6226d commit 9366c4a

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

cmd/snowsaw/bootstrap/bootstrap.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,30 @@ func NewBootstrapCmd() *cobra.Command {
3737
bootstrapCmd := &cobra.Command{
3838
Use: "bootstrap",
3939
Short: "Bootstraps all configured snowblocks",
40+
Long: `Bootstraps all configured snowblocks
41+
To process individual snowblocks a list of space-separated paths can be passed as arguments.
42+
`,
4043
Run: func(cmd *cobra.Command, args []string) {
4144
o.prepare(cmd, args)
4245
o.run(cmd, args)
4346
},
4447
}
45-
46-
bootstrapCmd.Flags().StringSliceVarP(
47-
&o.SnowblockPaths, "snowblocks", "s", []string{}, "comma-separated paths to individual snowblock directories")
48-
4948
return bootstrapCmd
5049
}
5150

5251
func (o *cmdOptions) prepare(cmd *cobra.Command, args []string) {
5352
// Use explicit snowblocks if specified, otherwise find all snowblocks within the base directories.
54-
if len(o.SnowblockPaths) > 0 {
53+
if len(args) > 0 {
5554
prt.Debugf("Using individual snowblocks instead of configured base directories(s): %s",
56-
color.CyanString("%v", o.SnowblockPaths))
57-
config.AppConfig.Snowblocks.Paths = o.SnowblockPaths
55+
color.CyanString("%v", args))
56+
config.AppConfig.Snowblocks.Paths = args
5857
} else {
5958
if err := o.readSnowblockDirectories(); err != nil {
6059
prt.Errorf("Failed to read snowblocks from base directories: %v", err)
6160
os.Exit(1)
6261
}
63-
o.SnowblockPaths = config.AppConfig.Snowblocks.Paths
6462
}
63+
o.SnowblockPaths = config.AppConfig.Snowblocks.Paths
6564
}
6665

6766
func (o *cmdOptions) readSnowblockDirectories() error {

pkg/snowblock/snowblock.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ func (s *Snowblock) Validate(taskRunner map[string]api.TaskRunner) error {
101101
// Try to read and encode the task objects when the directory contains a configuration file.
102102
configFilePath := filepath.Join(s.Path, fmt.Sprintf("%s.%s", api.ConfigurationFileName, encoder.ExtensionsJson))
103103
if configLoadErr := loadConfigFile(configFilePath, &s.TaskObjects); configLoadErr != nil {
104-
prt.Debugf("Ignoring snowblock directory %s without valid configuration file: %s: %v",
105-
color.CyanString(filepath.Base(s.Path)), color.BlueString(configFilePath), configLoadErr)
104+
prt.Debugf("Ignoring snowblock directory %s: %v",
105+
color.CyanString(filepath.Base(s.Path)), configLoadErr)
106106
return nil
107107
}
108108

0 commit comments

Comments
 (0)