mirror of
https://github.com/lukaszraczylo/harness-sync.git
synced 2026-10-13 00:48:30 +00:00
feat: add internal/ui prompts + init subcommand
- internal/ui/prompts.go: MultiSelect with huh TUI + WithNonInteractive for tests - internal/cli/init.go: NewInit cobra command with --from/--no-prompt flags - internal/cli/init_test.go: TestInitImportWritesCanonical - internal/cli/root.go: add resolveRoot helper (shared by profile/rollback/show/init) - go.mod: add github.com/charmbracelet/huh v1.0.0 as direct dep
This commit is contained in:
+10
-2
@@ -9,15 +9,23 @@ import (
|
||||
// NewDiff returns the `diff` subcommand. It is a shorthand for
|
||||
// `apply --dry-run` and shows pending changes without writing.
|
||||
func NewDiff(reg *adapter.Registry) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
var root string
|
||||
cmd := &cobra.Command{
|
||||
Use: "diff [harness...]",
|
||||
Short: "Show pending changes (alias for `apply --dry-run`)",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
apply := NewApply(reg)
|
||||
apply.SetOut(cmd.OutOrStdout())
|
||||
apply.SetErr(cmd.ErrOrStderr())
|
||||
apply.SetArgs(append([]string{"--dry-run"}, args...))
|
||||
applyArgs := []string{"--dry-run"}
|
||||
if root != "" {
|
||||
applyArgs = append(applyArgs, "--root", root)
|
||||
}
|
||||
applyArgs = append(applyArgs, args...)
|
||||
apply.SetArgs(applyArgs)
|
||||
return apply.Execute()
|
||||
},
|
||||
}
|
||||
cmd.Flags().StringVar(&root, "root", "", "canonical root (default ~/.config/harness-sync)")
|
||||
return cmd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user