diff --git a/README.md b/README.md index 75019b2..2977930 100644 --- a/README.md +++ b/README.md @@ -96,18 +96,16 @@ menlo config default-robot Or interactively: ```bash -menlo config default-robot +menlo robot connect ``` ## Configuration Configuration is stored in: -- macOS: `~/Library/Application Support/menlo/config.yaml` -- Linux: `~/.config/menlo/config.yaml` -- Windows: `%APPDATA%\menlo\config.yaml` +- `~/.menlo/config.yaml` # Uninstall ```bash sh -c "$(curl -fsSL https://raw.githubusercontent.com/menloresearch/cli/release/uninstall.sh)" -``` \ No newline at end of file +``` diff --git a/install.sh b/install.sh index 38603f6..4cee4e4 100755 --- a/install.sh +++ b/install.sh @@ -39,14 +39,9 @@ detect_arch() { esac } -# Detect config directory (matches Go's os.UserConfigDir) +# Detect config directory (matches Go's os.UserHomeDir + ~/.menlo) detect_config_dir() { - case "$(uname -s)" in - Darwin*) echo "$HOME/Library/Application Support";; - Linux*) echo "$HOME/.config";; - CYGWIN*|MINGW*) echo "$APPDATA";; - *) echo "$HOME/.config";; - esac + echo "$HOME/.menlo" } # Get latest version from GitHub @@ -125,8 +120,7 @@ install() { fi # Write version to config (preserve existing config) - CONFIG_BASE_DIR=$(detect_config_dir) - CONFIG_DIR="$CONFIG_BASE_DIR/menlo" + CONFIG_DIR=$(detect_config_dir) mkdir -p "$CONFIG_DIR" CONFIG_FILE="$CONFIG_DIR/config.yaml" if [ -f "$CONFIG_FILE" ]; then @@ -232,4 +226,4 @@ while [ $# -gt 0 ]; do done # Run install -install \ No newline at end of file +install diff --git a/internal/clients/platform/platform.go b/internal/clients/platform/platform.go index 614d568..7e40aa2 100644 --- a/internal/clients/platform/platform.go +++ b/internal/clients/platform/platform.go @@ -42,7 +42,7 @@ func NewClient() (*Client, error) { // Battery represents battery status type Battery struct { - Level int `json:"level"` + Level int `json:"level"` Charging bool `json:"charging"` } diff --git a/internal/commands/config.go b/internal/commands/config.go index 5d343ff..f261662 100644 --- a/internal/commands/config.go +++ b/internal/commands/config.go @@ -14,22 +14,6 @@ var configCmd = &cobra.Command{ Short: "Manage configuration", } -var defaultRobotCmd = &cobra.Command{ - Use: "default-robot [robot-id]", - Short: "Set or show the default robot", - Args: cobra.MaximumNArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - if len(args) == 0 { - // Interactive mode - show selection - return runRobotSelector() - } - - // Set robot ID directly - robotID := args[0] - return saveDefaultRobot(robotID) - }, -} - var apikeyCmd = &cobra.Command{ Use: "apikey [key]", Short: "Manage your API key", @@ -39,7 +23,7 @@ var apikeyCmd = &cobra.Command{ // Show current or instructions cfg, err := config.Load() if err != nil { - if os.IsNotExist(err) { + if config.IsNotExist(err) { fmt.Println("Get your API key from: https://platform.menlo.ai/account/api-keys") fmt.Println("Then run: menlo config apikey ") return nil @@ -98,7 +82,10 @@ func runRobotSelector() error { func saveDefaultRobot(robotID string) error { cfg, err := config.Load() if err != nil { - return err + if !config.IsNotExist(err) { + return err + } + cfg = config.DefaultConfig() } cfg.DefaultRobotID = robotID @@ -128,7 +115,7 @@ func saveDefaultRobot(robotID string) error { func saveAPIKey(apiKey string) error { cfg, err := config.Load() if err != nil { - if !os.IsNotExist(err) { + if !config.IsNotExist(err) { return err } cfg = config.DefaultConfig() @@ -159,6 +146,5 @@ func saveAPIKey(apiKey string) error { } func init() { - configCmd.AddCommand(defaultRobotCmd) configCmd.AddCommand(apikeyCmd) -} \ No newline at end of file +} diff --git a/internal/commands/robot.go b/internal/commands/robot.go index 47f88bc..d17428a 100644 --- a/internal/commands/robot.go +++ b/internal/commands/robot.go @@ -275,9 +275,9 @@ func createRobotSession(robotID string) error { meetURL := generateMeetLink(session.SFUEndpoint, session.WebRTCToken) fmt.Printf("Session created for robot %s\n\n", robotID) - fmt.Printf("SFU Endpoint: %s\n", session.SFUEndpoint) - fmt.Printf("WebRTC Token: %s\n\n", session.WebRTCToken) - fmt.Printf("Join URL: %s\n", meetURL) + fmt.Printf("Connection Endpoint:\n%s\n\n", session.SFUEndpoint) + fmt.Printf("Agent Token:\n%s\n\n", session.WebRTCToken) + fmt.Printf("Debug View:\n%s\n", meetURL) return nil } @@ -351,9 +351,9 @@ func init() { robotSnapshotCmd.Flags().String("robot-id", "", "Robot ID") robotCmd.AddCommand(robotListCmd) robotCmd.AddCommand(robotStatusCmd) - // robotCmd.AddCommand(robotActionCmd) // disabled + robotCmd.AddCommand(robotActionCmd) robotCmd.AddCommand(robotSessionCmd) // robotCmd.AddCommand(robotSnapshotCmd) // disabled robotCmd.AddCommand(robotConnectCmd) rootCmd.AddCommand(robotCmd) -} \ No newline at end of file +} diff --git a/internal/commands/root.go b/internal/commands/root.go index 52db3b5..25d2362 100644 --- a/internal/commands/root.go +++ b/internal/commands/root.go @@ -12,6 +12,7 @@ var rootCmd = &cobra.Command{ Long: `A CLI tool for Menlo research and development.`, DisableAutoGenTag: true, SilenceUsage: true, + Version: versionString(), } func Execute() { @@ -21,5 +22,7 @@ func Execute() { } func init() { + rootCmd.SetVersionTemplate("{{printf \"%s %s\\n\" .Name .Version}}") + rootCmd.Flags().BoolP("version", "V", false, "Print the version number") rootCmd.AddCommand(configCmd) -} \ No newline at end of file +} diff --git a/internal/commands/version.go b/internal/commands/version.go index 818e239..2879bf8 100644 --- a/internal/commands/version.go +++ b/internal/commands/version.go @@ -1,31 +1,19 @@ package commands import ( - "fmt" - "github.com/menloresearch/cli/internal/config" - "github.com/spf13/cobra" ) -var versionCmd = &cobra.Command{ - Use: "version", - Short: "Print the version number", - Run: func(cmd *cobra.Command, args []string) { - cfg, err := config.Load() - if err != nil { - // If no config, use default - cfg = config.DefaultConfig() - } +func versionString() string { + cfg, err := config.Load() + if err != nil { + cfg = config.DefaultConfig() + } - version := cfg.Version - if version == "" { - version = "dev" - } + version := cfg.Version + if version == "" { + return "dev" + } - fmt.Printf("menlo %s\n", version) - }, + return version } - -func init() { - rootCmd.AddCommand(versionCmd) -} \ No newline at end of file diff --git a/internal/config/config.go b/internal/config/config.go index 7b8a261..dfd6a2d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -31,11 +31,11 @@ func (c *Config) SetDefaults() { } func ConfigDir() (string, error) { - dir, err := os.UserConfigDir() + homeDir, err := os.UserHomeDir() if err != nil { return "", err } - return filepath.Join(dir, "menlo"), nil + return filepath.Join(homeDir, ".menlo"), nil } func ConfigPath() (string, error) { diff --git a/uninstall.sh b/uninstall.sh index 69693ac..07988a7 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -19,14 +19,9 @@ log_error() { printf "${RED}[ERROR]${NC} %s\n" "$1" } -# Detect config directory (matches Go's os.UserConfigDir) +# Detect config directory (matches Go's os.UserHomeDir + ~/.menlo) detect_config_dir() { - case "$(uname -s)" in - Darwin*) echo "$HOME/Library/Application Support";; - Linux*) echo "$HOME/.config";; - CYGWIN*|MINGW*) echo "$APPDATA";; - *) echo "$HOME/.config";; - esac + echo "$HOME/.menlo" } # Prompt user for confirmation @@ -60,8 +55,7 @@ uninstall() { fi # Detect config directory - CONFIG_BASE_DIR=$(detect_config_dir) - CONFIG_DIR="$CONFIG_BASE_DIR/menlo" + CONFIG_DIR=$(detect_config_dir) # Ask about config removal if [ -d "$CONFIG_DIR" ]; then @@ -132,4 +126,4 @@ while [ $# -gt 0 ]; do done # Run uninstall -uninstall \ No newline at end of file +uninstall