homelab/services/parts-inventory/cli/cmd/root.go
Dan V deb6c38d7b chore: commit homelab setup — deployment, services, orchestration, skill
- Add .gitignore: exclude compiled binaries, build artifacts, and Helm
  values files containing real secrets (authentik, prometheus)
- Add all Kubernetes deployment manifests (deployment/)
- Add services source code: ha-sync, device-inventory, games-console,
  paperclip, parts-inventory
- Add Ansible orchestration: playbooks, roles, inventory, cloud-init
- Add hardware specs, execution plans, scripts, HOMELAB.md
- Add skills/homelab/SKILL.md + skills/install.sh to preserve Copilot skill
- Remove previously-tracked inventory-cli binary from git index

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-09 08:10:32 +02:00

50 lines
906 B
Go

package cmd
import (
"fmt"
"os"
"parts-cli/internal/client"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var rootCmd = &cobra.Command{
Use: "parts",
Short: "CLI for the parts inventory API",
}
// Execute runs the root command.
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func init() {
cobra.OnInitialize(initConfig)
}
func initConfig() {
viper.SetConfigName(".parts-inventory")
viper.SetConfigType("yaml")
viper.AddConfigPath("$HOME")
home, err := os.UserHomeDir()
if err == nil {
viper.AddConfigPath(home)
}
viper.SetEnvPrefix("")
viper.BindEnv("api_url", "PARTS_API_URL") //nolint:errcheck
viper.SetDefault("api_url", "http://localhost:3001")
_ = viper.ReadInConfig()
}
// GetClient returns a configured API client.
func GetClient() *client.Client {
return client.New(viper.GetString("api_url"))
}