Documentation
¶
Overview ¶
*
- Copyright © 2025 Magdiel Campelo <github.com/MagdielCAS/magi-cli>
- This file is part of the magi-cli
*
*
- Copyright © 2025 Magdiel Campelo <github.com/MagdielCAS/magi-cli>
- This file is part of the magi-cli
*
*
- Copyright © 2025 Magdiel Campelo <github.com/MagdielCAS/magi-cli>
- This file is part of the magi-cli
*
*
- Copyright © 2025 Magdiel Campelo <github.com/MagdielCAS/magi-cli>
- This file is part of the magi-cli
*
*
- Copyright © 2025 Magdiel Campelo <github.com/MagdielCAS/magi-cli>
- This file is part of the magi-cli
*
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var GetCmd = &cobra.Command{ Use: "get [key]", Short: "Gets a configuration value", Long: `Gets a configuration value. Usage: magi config get [key] Examples: # Get the value of a key magi config get api.model Run 'magi config get --help' for more information on a specific command.`, Args: cobra.ExactArgs(1), Run: runGet, }
View Source
var InitCmd = &cobra.Command{ Use: "init", Short: "Initialize a local configuration file", Long: `Initialize a local configuration file (.magi.yaml) in the current directory. This file will override the global configuration (but only the ones with the same key). The goal is to have custom envs like models or keys for different workspaces. Usage: magi config init Examples: # Initialize a local configuration file magi config init `, Run: func(cmd *cobra.Command, args []string) { cwd, err := os.Getwd() if err != nil { pterm.Error.Printf("Error getting current working directory: %v\n", err) return } configPath := filepath.Join(cwd, ".magi.yaml") if _, err := os.Stat(configPath); err == nil { pterm.Warning.Println("Local configuration file already exists") return } template := `# Magi CLI Configuration api: # API provider (e.g., openai, custom) provider: openai # Base URL for custom OpenAI compatible API (optional) base_url: "" # Your API key key: "" # Model for light tasks (e.g., gpt-3.5-turbo) light_model: gpt-3.5-turbo # Model for heavy tasks (e.g., gpt-4) heavy_model: gpt-4 # Fallback model (e.g., gpt-3.5-turbo) fallback_model: gpt-3.5-turbo output: # Default output format (e.g., text, json, yaml) format: text # Enable color output color: true cache: # Enable caching enabled: true # Cache TTL in seconds ttl: 3600 ` if err := os.WriteFile(configPath, []byte(template), 0644); err != nil { pterm.Error.Printf("Error creating local configuration file: %v\n", err) return } pterm.Success.Printf("Local configuration file created at %s\n", configPath) gitignorePath := filepath.Join(cwd, ".gitignore") if _, err := os.Stat(gitignorePath); err == nil { if err := addToGitignore(gitignorePath, ".magi.yaml"); err != nil { pterm.Error.Printf("Error updating .gitignore: %v\n", err) } else { pterm.Success.Println("Added .magi.yaml to .gitignore") } } }, }
View Source
var ListCmd = &cobra.Command{
Use: "list",
Short: "Lists all configuration values",
Long: `Lists all configuration values.
Usage:
magi config list
Examples:
# List all values
magi config list
Run 'magi config list --help' for more information on a specific command.`,
Run: runList,
}
View Source
var ResetCmd = &cobra.Command{
Use: "reset",
Short: "Resets the configuration",
Long: `Resets the configuration to its default values.
Usage:
magi config reset
Examples:
# Reset the configuration
magi config reset
Run 'magi config reset --help' for more information on a specific command.`,
Run: runReset,
}
View Source
var SetCmd = &cobra.Command{ Use: "set [key] [value]", Short: "Sets a configuration value", Long: `Sets a configuration value. Usage: magi config set [key] [value] Examples: # Set the value of a key magi config set api.model gpt-4 Run 'magi config set --help' for more information on a specific command.`, Args: cobra.ExactArgs(2), Run: runSet, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.