From ef3153ffc1974dad850395d472e2bef224516da3 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Sun, 5 May 2024 14:45:58 -0500 Subject: [PATCH] go back to using the standard cobra layout --- pkgs/oizys/oizys-go/cmd/boot.go | 20 +++++++++++ pkgs/oizys/oizys-go/cmd/build.go | 21 ++++++++++++ pkgs/oizys/oizys-go/cmd/cache.go | 25 ++++++++++++++ pkgs/oizys/oizys-go/cmd/dry.go | 19 +++++++++++ pkgs/oizys/oizys-go/cmd/output.go | 21 ++++++++++++ pkgs/oizys/oizys-go/cmd/root.go | 57 ------------------------------- pkgs/oizys/oizys-go/cmd/switch.go | 19 +++++++++++ 7 files changed, 125 insertions(+), 57 deletions(-) create mode 100644 pkgs/oizys/oizys-go/cmd/boot.go create mode 100644 pkgs/oizys/oizys-go/cmd/build.go create mode 100644 pkgs/oizys/oizys-go/cmd/cache.go create mode 100644 pkgs/oizys/oizys-go/cmd/dry.go create mode 100644 pkgs/oizys/oizys-go/cmd/output.go create mode 100644 pkgs/oizys/oizys-go/cmd/switch.go diff --git a/pkgs/oizys/oizys-go/cmd/boot.go b/pkgs/oizys/oizys-go/cmd/boot.go new file mode 100644 index 0000000..d3b7ba1 --- /dev/null +++ b/pkgs/oizys/oizys-go/cmd/boot.go @@ -0,0 +1,20 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "oizys/pkg/oizys" +) + + + +var bootCmd = &cobra.Command{ + Use: "boot", + Short: "nixos rebuild boot", + Run: func(cmd *cobra.Command, args []string) { + oizys.NixosRebuild("boot", flake) + }, +} + +func init() { + rootCmd.AddCommand(bootCmd) +} diff --git a/pkgs/oizys/oizys-go/cmd/build.go b/pkgs/oizys/oizys-go/cmd/build.go new file mode 100644 index 0000000..a7da2f0 --- /dev/null +++ b/pkgs/oizys/oizys-go/cmd/build.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "oizys/pkg/oizys" +) + + +var buildCmd = &cobra.Command{ + Use: "build", + Short: "A brief description of your command", + Run: func(cmd *cobra.Command, args []string) { + oizys.NixBuild(oizys.Output(flake, host), args...) + }, +} + + + +func init() { + rootCmd.AddCommand(buildCmd) +} diff --git a/pkgs/oizys/oizys-go/cmd/cache.go b/pkgs/oizys/oizys-go/cmd/cache.go new file mode 100644 index 0000000..93a0b87 --- /dev/null +++ b/pkgs/oizys/oizys-go/cmd/cache.go @@ -0,0 +1,25 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "oizys/pkg/oizys" +) + +var cacheCmd = &cobra.Command{ + Use: "cache", + Short: "build and push to cachix", + Run: func(cmd *cobra.Command, args []string) { + oizys.CacheBuild(oizys.Output(flake, host), cacheName, args...) + }, +} + +func init() { + cacheCmd.Flags().StringVarP( + &cacheName, + "cache", + "c", + "daylin", + "name of cachix binary cache", + ) + rootCmd.AddCommand(cacheCmd) +} diff --git a/pkgs/oizys/oizys-go/cmd/dry.go b/pkgs/oizys/oizys-go/cmd/dry.go new file mode 100644 index 0000000..6783d35 --- /dev/null +++ b/pkgs/oizys/oizys-go/cmd/dry.go @@ -0,0 +1,19 @@ +package cmd + +import ( + + "github.com/spf13/cobra" + "oizys/pkg/oizys" +) + +var dryCmd = &cobra.Command{ + Use: "dry", + Short: "poor man's nix flake check", + Run: func(cmd *cobra.Command, args []string) { + oizys.NixDryRun(oizys.Output(flake, host)) + }, +} + +func init() { + rootCmd.AddCommand(dryCmd) +} diff --git a/pkgs/oizys/oizys-go/cmd/output.go b/pkgs/oizys/oizys-go/cmd/output.go new file mode 100644 index 0000000..e00c521 --- /dev/null +++ b/pkgs/oizys/oizys-go/cmd/output.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" + "oizys/pkg/oizys" +) + + +var outputCmd = &cobra.Command{ + Use: "output", + Short: "show nixosConfiguration attr", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println(oizys.Output(flake, host)) + }, +} + +func init() { + rootCmd.AddCommand(outputCmd) +} diff --git a/pkgs/oizys/oizys-go/cmd/root.go b/pkgs/oizys/oizys-go/cmd/root.go index fb57ec8..b483dff 100644 --- a/pkgs/oizys/oizys-go/cmd/root.go +++ b/pkgs/oizys/oizys-go/cmd/root.go @@ -9,7 +9,6 @@ import ( cc "github.com/ivanpirog/coloredcobra" "github.com/spf13/cobra" - "oizys/pkg/oizys" ) func setFlake() { @@ -70,65 +69,9 @@ var rootCmd = &cobra.Command{ }, } -var dryCmd = &cobra.Command{ - Use: "dry", - Short: "poor man's nix flake check", - Run: func(cmd *cobra.Command, args []string) { - oizys.NixDryRun(oizys.Output(flake, host)) - }, -} - -var outputCmd = &cobra.Command{ - Use: "output", - Short: "show nixosConfiguration attr", - Run: func(cmd *cobra.Command, args []string) { - fmt.Print(oizys.Output(flake, host)) - }, -} - -var bootCmd = &cobra.Command{ - Use: "boot", - Short: "nixos rebuild boot", - Run: func(cmd *cobra.Command, args []string) { - oizys.NixosRebuild("boot", flake) - }, -} - -var switchCmd = &cobra.Command{ - Use: "switch", - Short: "nixos rebuild switch", - Run: func(cmd *cobra.Command, args []string) { - oizys.NixosRebuild("switch", flake, args...) - }, -} - -var cacheCmd = &cobra.Command{ - Use: "cache", - Short: "build and push to cachix", - Run: func(cmd *cobra.Command, args []string) { - oizys.CacheBuild(oizys.Output(flake, host), cacheName, args...) - }, -} - -var buildCmd = &cobra.Command{ - Use: "build", - Short: "A brief description of your command", - Run: func(cmd *cobra.Command, args []string) { - oizys.NixBuild(oizys.Output(flake, host), args...) - }, -} - - func init() { rootCmd.CompletionOptions.HiddenDefaultCmd = true rootCmd.PersistentFlags().StringVar(&flake, "flake", "", "path to flake ($OIZYS_DIR or $HOME/oizys)") rootCmd.PersistentFlags().StringVar(&host, "host", "", "host to build (current host)") - rootCmd.AddCommand(dryCmd) - rootCmd.AddCommand(outputCmd) - rootCmd.AddCommand(bootCmd) - rootCmd.AddCommand(buildCmd) - rootCmd.AddCommand(switchCmd) - rootCmd.AddCommand(cacheCmd) - cacheCmd.Flags().StringVarP(&cacheName, "cache", "c", "daylin", "name of cachix binary cache") } diff --git a/pkgs/oizys/oizys-go/cmd/switch.go b/pkgs/oizys/oizys-go/cmd/switch.go new file mode 100644 index 0000000..9ccda3c --- /dev/null +++ b/pkgs/oizys/oizys-go/cmd/switch.go @@ -0,0 +1,19 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "oizys/pkg/oizys" +) + +var switchCmd = &cobra.Command{ + Use: "switch", + Short: "nixos rebuild switch", + Run: func(cmd *cobra.Command, args []string) { + oizys.NixosRebuild("switch", flake, args...) + }, +} + + +func init() { + rootCmd.AddCommand(switchCmd) +}