mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-11-05 01:53:15 -06:00
go back to using the standard cobra layout
This commit is contained in:
parent
bcb27082ff
commit
ef3153ffc1
7 changed files with 125 additions and 57 deletions
20
pkgs/oizys/oizys-go/cmd/boot.go
Normal file
20
pkgs/oizys/oizys-go/cmd/boot.go
Normal file
|
@ -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)
|
||||
}
|
21
pkgs/oizys/oizys-go/cmd/build.go
Normal file
21
pkgs/oizys/oizys-go/cmd/build.go
Normal file
|
@ -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)
|
||||
}
|
25
pkgs/oizys/oizys-go/cmd/cache.go
Normal file
25
pkgs/oizys/oizys-go/cmd/cache.go
Normal file
|
@ -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)
|
||||
}
|
19
pkgs/oizys/oizys-go/cmd/dry.go
Normal file
19
pkgs/oizys/oizys-go/cmd/dry.go
Normal file
|
@ -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)
|
||||
}
|
21
pkgs/oizys/oizys-go/cmd/output.go
Normal file
21
pkgs/oizys/oizys-go/cmd/output.go
Normal file
|
@ -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)
|
||||
}
|
|
@ -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")
|
||||
}
|
||||
|
|
19
pkgs/oizys/oizys-go/cmd/switch.go
Normal file
19
pkgs/oizys/oizys-go/cmd/switch.go
Normal file
|
@ -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)
|
||||
}
|
Loading…
Reference in a new issue