diff --git a/cmd/bundle.go b/cmd/bundle.go index afd9bbd2..938f50c2 100644 --- a/cmd/bundle.go +++ b/cmd/bundle.go @@ -9,7 +9,7 @@ import ( ) var bundleCommand = &cobra.Command{ - Use: "bundle [file or directory] [outfile]", + Use: "bundle [entryfile] [outfile]", Short: "Bundle an app", Args: cobra.ExactArgs(2), Run: func(cmd *cobra.Command, args []string) { diff --git a/cmd/init.go b/cmd/init.go index 78b1a013..d113f2c6 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -11,14 +11,15 @@ import ( ) var ( - force bool - gtk int + force bool + gtk int + initDirectory string ) var initCommand = &cobra.Command{ - Use: "init [directory]", + Use: "init", Short: "Initialize a project directory", - Long: "Setup files needed by TypeScript and generate types", + Long: "Initialize a project directory by setting up files needed by TypeScript, generating types and setting up a basic bar example", Args: cobra.MaximumNArgs(1), Run: initConfig, } @@ -28,6 +29,7 @@ func init() { f.IntVarP(>k, "gtk", "g", 3, "use this gtk version") f.BoolVarP(&force, "force", "f", false, "override existing files") + f.StringVarP(&initDirectory, "directory", "d", defaultConfigDir(), "target directory") } func getDataFile(name string) string { diff --git a/cmd/run.go b/cmd/run.go index 74160e64..34e7286d 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -9,12 +9,14 @@ import ( "github.com/spf13/cobra" ) -var gtk4 bool +var ( + gtk4 bool + targetDir string +) var runCommand = &cobra.Command{ - Use: "run [optional file or directory]", + Use: "run [file]", Short: "Run an app", - Long: `Run a given app. Defaults to ` + defaultConfigDir(), Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { if len(args) > 0 { @@ -35,14 +37,18 @@ var runCommand = &cobra.Command{ } } else { - dir := defaultConfigDir() - run(getAppEntry(dir), dir) + run(getAppEntry(targetDir), targetDir) } }, } func init() { - runCommand.Flags().BoolVar(>k4, "gtk4", false, "preload Gtk4LayerShell") + f := runCommand.Flags() + f.BoolVar(>k4, "gtk4", false, "preload Gtk4LayerShell") + f.StringVarP(&targetDir, "directory", "d", defaultConfigDir(), + `directory to search for an "app" entry file +when no positional argument is given +`+"\b") } func getOutfile() string { diff --git a/cmd/types.go b/cmd/types.go index a54d7230..137638f9 100644 --- a/cmd/types.go +++ b/cmd/types.go @@ -13,7 +13,7 @@ import ( ) var ( - typesConfigDir string + typesTonfigDir string ignoreModules []string ) @@ -21,12 +21,12 @@ var typesCommand = &cobra.Command{ Use: "types [pattern]", Short: "Generate TypeScript types", Args: cobra.MaximumNArgs(1), - Example: ` types Astal* --ignore Gtk3 --ignore Astal3`, + Example: ` ags types Astal* --ignore Gtk3 --ignore Astal3`, Run: func(cmd *cobra.Command, args []string) { if len(args) > 0 { - genTypes(typesConfigDir, args[0]) + genTypes(typesTonfigDir, args[0]) } else { - genTypes(typesConfigDir, "*") + genTypes(typesTonfigDir, "*") } }, } @@ -34,7 +34,7 @@ var typesCommand = &cobra.Command{ func init() { f := typesCommand.Flags() - f.StringVarP(&typesConfigDir, "config", "c", defaultConfigDir(), "configuration directory") + f.StringVarP(&typesTonfigDir, "directory", "d", defaultConfigDir(), "target directory") f.StringArrayVarP(&ignoreModules, "ignore", "i", []string{}, "modules that should be ignored") }