feat(cli): add aliases to commands

This commit is contained in:
Patryk Hegenberg 2025-01-23 07:59:26 +01:00
parent 53a50f2be4
commit 70dbc9e062
6 changed files with 20 additions and 27 deletions

View file

@ -12,6 +12,7 @@ import (
var RootCmd = &cobra.Command{
Use: "system_setup_tool",
Short: "Installs packages based on TOML configuration",
Version: "0.4.0",
Run: tui.Run,
}

View file

@ -15,6 +15,7 @@ var installCmd = &cobra.Command{
Use: "install [package_name]",
Short: "Install a package with the specified package manager",
Args: cobra.ExactArgs(1),
Aliases: []string{"i"},
Run: func(cmd *cobra.Command, args []string) {
packageName := args[0]
managerName, _ := cmd.Flags().GetString("manager")

View file

@ -16,6 +16,7 @@ var searchCmd = &cobra.Command{
Use: "search [package_name]",
Short: "Search for a package across package managers (will search in os|flatpak|homebrew)",
Args: cobra.ExactArgs(1),
Aliases: []string{"s"},
Run: func(cmd *cobra.Command, args []string) {
packageName := args[0]
managerName, _ := cmd.Flags().GetString("manager")

View file

@ -16,6 +16,7 @@ var updateCmd = &cobra.Command{
Short: "update a package with the specified package manager.",
Long: "update a package with the specified package manager.\nIf no package specified, all packages for the package manager will be updated",
Args: cobra.ExactArgs(1),
Aliases: []string{"u"},
Run: func(cmd *cobra.Command, args []string) {
packageName := args[0]
managerName, _ := cmd.Flags().GetString("manager")

View file

@ -101,8 +101,6 @@ packages = [
'hyprutils',
'kitty',
'mako',
'SwayNotificationCenter',
'SwayNotificationCenter-zsh-completion',
'mpv',
'pidgin',
'remmina',
@ -110,7 +108,6 @@ packages = [
'virt-manager',
'vlc',
'waybar',
'nwg-panel',
'nwg-look',
'xdg-desktop-portal-hyprland',
'zathura',

View file

@ -16,9 +16,8 @@ import (
// A build step that requires additional params, or platform specific steps for example
func Build() error {
mg.Deps(InstallDeps)
fmt.Println("Building...")
cmd := exec.Command("go", "build", "-o", "system_setup_tool", ".")
cmd := exec.Command("go", "build", "-o", "sst", ".")
return cmd.Run()
}
@ -26,20 +25,13 @@ func Build() error {
func Install() error {
mg.Deps(Build)
fmt.Println("Installing...")
return os.Rename("./system_setup_tool", "/usr/bin/system_setup_tool")
}
// Manage your deps, or running package managers.
func InstallDeps() error {
fmt.Println("Installing Deps...")
cmd := exec.Command("go", "get", "github.com/stretchr/piglatin")
return cmd.Run()
return os.Rename("./sst", "~/.local/bin/sst")
}
// Clean up after yourself
func Clean() {
fmt.Println("Cleaning...")
os.RemoveAll("MyApp")
os.RemoveAll("system_setup_tool")
}
// Use gofmt to format your code