mirror of
https://github.com/lukaszraczylo/harness-sync.git
synced 2026-10-15 01:07:27 +00:00
feat(cli): add apply subcommand
This commit is contained in:
+20
-1
@@ -1,7 +1,13 @@
|
||||
// Package cli provides the cobra command tree for harness-sync.
|
||||
package cli
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewRoot(version string) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
@@ -11,3 +17,16 @@ func NewRoot(version string) *cobra.Command {
|
||||
SilenceUsage: true,
|
||||
}
|
||||
}
|
||||
|
||||
// resolveRoot returns the canonical root: the flag value when non-empty,
|
||||
// else $HOME/.config/harness-sync.
|
||||
func resolveRoot(flag string) (string, error) {
|
||||
if flag != "" {
|
||||
return flag, nil
|
||||
}
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("resolve home dir: %w", err)
|
||||
}
|
||||
return filepath.Join(home, ".config", "harness-sync"), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user