Skip to content

Commit

Permalink
rename flag config -> directory
Browse files Browse the repository at this point in the history
its not being used as a config but as a target directory so it make
sense to rename it to directory
  • Loading branch information
Aylur committed Nov 8, 2024
1 parent e04f229 commit 250d501
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cmd/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 6 additions & 4 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -28,6 +29,7 @@ func init() {

f.IntVarP(&gtk, "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 {
Expand Down
18 changes: 12 additions & 6 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -35,14 +37,18 @@ var runCommand = &cobra.Command{
}

} else {
dir := defaultConfigDir()
run(getAppEntry(dir), dir)
run(getAppEntry(targetDir), targetDir)
}
},
}

func init() {
runCommand.Flags().BoolVar(&gtk4, "gtk4", false, "preload Gtk4LayerShell")
f := runCommand.Flags()
f.BoolVar(&gtk4, "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 {
Expand Down
10 changes: 5 additions & 5 deletions cmd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ import (
)

var (
typesConfigDir string
typesTonfigDir string
ignoreModules []string
)

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, "*")
}
},
}

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")
}

Expand Down

0 comments on commit 250d501

Please sign in to comment.