Files
zeekay aa2e264111 feat: unified binary linking and nvm-style version management
New commands:
- lux link all: link all binaries (lux, luxd, netrunner)
- lux link <binary>: link specific binary
- lux node link: link luxd binary
- lux netrunner link: link netrunner binary
- lux self link: link CLI to ~/.lux/bin
- lux self install <version>: install specific CLI version
- lux self use <version>: switch CLI versions
- lux self list: list installed versions

Changes:
- Update install.sh to use ~/.lux/bin and add to PATH
- Update snapshot handling
- Standardize binary output to bin/ directory
2026-01-21 20:10:11 -08:00

55 lines
1.2 KiB
Go

// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
// Package selfcmd implements CLI self-management commands.
// This provides nvm-style version management for the Lux CLI itself.
package selfcmd
import (
"github.com/luxfi/cli/pkg/application"
"github.com/spf13/cobra"
)
var app *application.Lux
// NewCmd creates and returns the self command
func NewCmd(injectedApp *application.Lux, version string) *cobra.Command {
app = injectedApp
cmd := &cobra.Command{
Use: "self",
Short: "Manage the Lux CLI installation",
Long: `Commands for managing the Lux CLI installation.
Similar to nvm for Node.js, this allows you to:
- Link development builds to ~/.lux/bin/
- Install specific versions
- Switch between versions
- Self-update
EXAMPLES:
# Link current binary to ~/.lux/bin/lux
lux self link
# Install a specific version
lux self install v1.22.5
# List installed versions
lux self list
# Use a specific version
lux self use v1.22.5`,
Run: func(cmd *cobra.Command, _ []string) {
_ = cmd.Help()
},
}
cmd.AddCommand(newLinkCmd())
cmd.AddCommand(newListCmd())
cmd.AddCommand(newInstallCmd(version))
cmd.AddCommand(newUseCmd())
return cmd
}