mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 18:30:43 -06:00
add verbose flag to oizys dry
This commit is contained in:
parent
5e4629c1e0
commit
887fe2f49d
2 changed files with 22 additions and 9 deletions
|
@ -11,10 +11,19 @@ var dryCmd = &cobra.Command{
|
||||||
Short: "poor man's nix flake check",
|
Short: "poor man's nix flake check",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
oizys.CheckFlake(flake)
|
oizys.CheckFlake(flake)
|
||||||
oizys.NixDryRun(flake, host)
|
oizys.NixDryRun(flake, host, verbose)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var verbose bool
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(dryCmd)
|
rootCmd.AddCommand(dryCmd)
|
||||||
|
dryCmd.Flags().BoolVarP(
|
||||||
|
&verbose,
|
||||||
|
"verbose",
|
||||||
|
"v",
|
||||||
|
false,
|
||||||
|
"show verbose output",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,12 @@ func TerminalSize() (int, int) {
|
||||||
return w, h
|
return w, h
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseDryRunOutput(nixOutput string) {
|
func ParseDryRunOutput(nixOutput string, verbose bool) {
|
||||||
output := termenv.NewOutput(os.Stdout)
|
output := termenv.NewOutput(os.Stdout)
|
||||||
parts := strings.Split(nixOutput, "\nthese")
|
parts := strings.Split(nixOutput, "\nthese")
|
||||||
if len(parts) != 3 {
|
if len(parts) != 3 {
|
||||||
log.Println("no changes...")
|
log.Println("no changes...")
|
||||||
|
log.Println(output)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
built := strings.Split(strings.TrimSpace(parts[1]), "\n")[1:]
|
built := strings.Split(strings.TrimSpace(parts[1]), "\n")[1:]
|
||||||
|
@ -58,6 +59,8 @@ func ParseDryRunOutput(nixOutput string) {
|
||||||
rows = append(rows, table.Row{hash, name})
|
rows = append(rows, table.Row{hash, name})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if verbose {
|
||||||
|
|
||||||
w, _ := TerminalSize()
|
w, _ := TerminalSize()
|
||||||
columns := []table.Column{
|
columns := []table.Column{
|
||||||
{Title: "hash", Width: 34},
|
{Title: "hash", Width: 34},
|
||||||
|
@ -65,8 +68,9 @@ func ParseDryRunOutput(nixOutput string) {
|
||||||
}
|
}
|
||||||
ShowTable(columns, rows)
|
ShowTable(columns, rows)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func NixDryRun(flake string, host string) {
|
func NixDryRun(flake string, host string, verbose bool) {
|
||||||
output := termenv.NewOutput(os.Stdout)
|
output := termenv.NewOutput(os.Stdout)
|
||||||
path := Output(flake, host)
|
path := Output(flake, host)
|
||||||
cmd := exec.Command("nix", "build", path, "--dry-run")
|
cmd := exec.Command("nix", "build", path, "--dry-run")
|
||||||
|
@ -85,7 +89,7 @@ func NixDryRun(flake string, host string) {
|
||||||
fmt.Println(string(result))
|
fmt.Println(string(result))
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
ParseDryRunOutput(string(result))
|
ParseDryRunOutput(string(result), verbose)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NixosRebuild(subcmd string, flake string, rest ...string) {
|
func NixosRebuild(subcmd string, flake string, rest ...string) {
|
||||||
|
|
Loading…
Reference in a new issue