From d2ca243f60658ded0842955f07b3df5110412b83 Mon Sep 17 00:00:00 2001 From: Tayler Geiger Date: Sat, 20 Apr 2024 23:16:31 -0500 Subject: [PATCH] Rename to cpm, fix some descriptions --- .gitignore | 2 +- README.md | 12 ++++++------ cmd/disable.go | 2 +- cmd/disable_test.go | 6 +++--- cmd/enable.go | 8 +------- cmd/enable_test.go | 6 +++--- cmd/list.go | 13 ++++++------- cmd/list_test.go | 2 +- cmd/prune.go | 3 ++- cmd/prune_test.go | 2 +- cmd/remove.go | 2 +- cmd/remove_test.go | 6 +++--- cmd/root.go | 8 ++++---- go.mod | 2 +- internal/testutil/test-utils.go | 2 +- main.go | 2 +- 16 files changed, 36 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 047f46e..27e7755 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ copr-cli -copr-tool \ No newline at end of file +cpm \ No newline at end of file diff --git a/README.md b/README.md index f0c98a9..2056c0c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# copr-tool +# Copr Manager CLI app for managing Copr repos, written in Go. ## Usage -`copr-tool [OPTION] [REPO(s)...]` +`cpm [OPTION] [REPO(s)...]` ``` Options: @@ -20,8 +20,8 @@ Arguments: [REPO(s)...] One or more repository names formatted as `author/repo` Examples: - copr-tool enable kylegospo/bazzite yalter/niri - copr-tool disable kylegospo/bazzite - copr-tool remove kylegospo/bazzite - copr-tool list --all + cpm enable kylegospo/bazzite yalter/niri + cpm disable kylegospo/bazzite + cpm remove kylegospo/bazzite + cpm list --all ``` \ No newline at end of file diff --git a/cmd/disable.go b/cmd/disable.go index a43da5f..74aa2ab 100644 --- a/cmd/disable.go +++ b/cmd/disable.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/trgeiger/copr-tool/internal/app" + "github.com/trgeiger/cpm/internal/app" ) func NewDisableCmd(fs afero.Fs, out io.Writer) *cobra.Command { diff --git a/cmd/disable_test.go b/cmd/disable_test.go index 03612e2..10e8687 100644 --- a/cmd/disable_test.go +++ b/cmd/disable_test.go @@ -4,7 +4,7 @@ import ( "bytes" "testing" - "github.com/trgeiger/copr-tool/internal/testutil" + "github.com/trgeiger/cpm/internal/testutil" ) func TestDisableCmd(t *testing.T) { @@ -18,9 +18,9 @@ func TestDisableCmd(t *testing.T) { { name: "Disable invalid repo name", args: []string{ - "copr-tool", + "cpm", }, - expected: "invalid repository name: copr-tool\n", + expected: "invalid repository name: cpm\n", }, { name: "Repo does not exist", diff --git a/cmd/enable.go b/cmd/enable.go index 70c25f0..7279169 100644 --- a/cmd/enable.go +++ b/cmd/enable.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/trgeiger/copr-tool/internal/app" + "github.com/trgeiger/cpm/internal/app" ) func verifyCoprRepo(r *app.CoprRepo, fs afero.Fs) error { @@ -62,12 +62,6 @@ func NewEnableCmd(fs afero.Fs, out io.Writer) *cobra.Command { Aliases: []string{"add"}, Args: cobra.MinimumNArgs(1), Short: "Enable or add one or more Copr repositories.", - Long: `A longer description that spans multiple lines and likely contains examples - and usage of using your command. For example: - - Cobra is a CLI library for Go that empowers applications. - This application is a tool to generate the needed files - to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { for _, arg := range args { repo, err := app.NewCoprRepo(arg) diff --git a/cmd/enable_test.go b/cmd/enable_test.go index 8b0d4eb..66d96bb 100644 --- a/cmd/enable_test.go +++ b/cmd/enable_test.go @@ -4,7 +4,7 @@ import ( "bytes" "testing" - "github.com/trgeiger/copr-tool/internal/testutil" + "github.com/trgeiger/cpm/internal/testutil" ) func TestEnableCmd(t *testing.T) { @@ -28,9 +28,9 @@ func TestEnableCmd(t *testing.T) { { name: "Add invalid repo name", args: []string{ - "copr-tool", + "cpm", }, - expected: "invalid repository name: copr-tool\n", + expected: "invalid repository name: cpm\n", }, { name: "Repo does not exist", diff --git a/cmd/list.go b/cmd/list.go index 7daa6ba..52ce9ea 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/trgeiger/copr-tool/internal/app" + "github.com/trgeiger/cpm/internal/app" ) var ( @@ -41,12 +41,11 @@ func NewListCmd(fs afero.Fs, out io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "list", Short: "List installed Copr repositories", - Long: `A longer description that spans multiple lines and likely contains examples - and usage of using your command. For example: - - Cobra is a CLI library for Go that empowers applications. - This application is a tool to generate the needed files - to quickly create a Cobra application.`, + Long: `List all installed and enabled Copr repositories by default. +For example: + cpm list + cpm list --all + cpm list --disabled`, Run: func(cmd *cobra.Command, args []string) { var lists []app.RepoState if !disabled { diff --git a/cmd/list_test.go b/cmd/list_test.go index cd63045..97a348b 100644 --- a/cmd/list_test.go +++ b/cmd/list_test.go @@ -4,7 +4,7 @@ import ( "bytes" "testing" - "github.com/trgeiger/copr-tool/internal/testutil" + "github.com/trgeiger/cpm/internal/testutil" ) func TestListCmd(t *testing.T) { diff --git a/cmd/prune.go b/cmd/prune.go index 9f77f42..1a61ed0 100644 --- a/cmd/prune.go +++ b/cmd/prune.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/trgeiger/copr-tool/internal/app" + "github.com/trgeiger/cpm/internal/app" ) // pruneCmd represents the prune command @@ -32,6 +32,7 @@ func NewPruneCmd(fs afero.Fs, out io.Writer) *cobra.Command { return &cobra.Command{ Use: "prune", Short: "Remove duplicate repository configurations.", + Long: "Cleans Copr repository configuration files by removing duplicates and renaming the remaining files to standard format.", Run: func(cmd *cobra.Command, args []string) { repos, err := app.GetReposList(fs, out, app.Enabled) if err != nil { diff --git a/cmd/prune_test.go b/cmd/prune_test.go index 8aeabbf..ed15763 100644 --- a/cmd/prune_test.go +++ b/cmd/prune_test.go @@ -4,7 +4,7 @@ import ( "bytes" "testing" - "github.com/trgeiger/copr-tool/internal/testutil" + "github.com/trgeiger/cpm/internal/testutil" ) func TestPruneCmd(t *testing.T) { diff --git a/cmd/remove.go b/cmd/remove.go index 9d75e08..9a6d119 100644 --- a/cmd/remove.go +++ b/cmd/remove.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/trgeiger/copr-tool/internal/app" + "github.com/trgeiger/cpm/internal/app" ) func NewRemoveCmd(fs afero.Fs, out io.Writer) *cobra.Command { diff --git a/cmd/remove_test.go b/cmd/remove_test.go index a4048bd..4db2e4a 100644 --- a/cmd/remove_test.go +++ b/cmd/remove_test.go @@ -4,7 +4,7 @@ import ( "bytes" "testing" - "github.com/trgeiger/copr-tool/internal/testutil" + "github.com/trgeiger/cpm/internal/testutil" ) func TestRemoveCmd(t *testing.T) { @@ -18,9 +18,9 @@ func TestRemoveCmd(t *testing.T) { { name: "Remove invalid repo name", args: []string{ - "copr-tool", + "cpm", }, - expected: "invalid repository name: copr-tool\n", + expected: "invalid repository name: cpm\n", }, { name: "Remove uninstalled repo", diff --git a/cmd/root.go b/cmd/root.go index fe30ea5..1eeb8f4 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -23,7 +23,7 @@ func Execute(fs afero.Fs) { viper.SetFs(fs) if err := viper.ReadInConfig(); err != nil { if _, ok := err.(viper.ConfigFileNotFoundError); ok { - panic(fmt.Errorf("could not find /etc/os-release, copr-tool only functions on Fedora Linux systems: %w", err)) + panic(fmt.Errorf("could not find /etc/os-release, cpm only functions on Fedora Linux systems: %w", err)) } else { panic(fmt.Errorf("unknown fatal error: %w", err)) @@ -50,8 +50,8 @@ func Execute(fs afero.Fs) { func NewRootCmd(fs afero.Fs, out io.Writer) (*cobra.Command, error) { cmd := &cobra.Command{ - Use: "copr-tool", - Short: "A command line tool for managing Copr repositories", + Use: "cpm", + Short: "Copr Manager: a command line tool for managing Copr repositories", } cmd.AddCommand( @@ -71,7 +71,7 @@ func init() { // Cobra supports persistent flags, which, if defined here, // will be global for your application. - // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.copr-tool.yaml)") + // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cpm.yaml)") // Cobra also supports local flags, which will only run // when this action is called directly. diff --git a/go.mod b/go.mod index 7b96645..ae8b47c 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/trgeiger/copr-tool +module github.com/trgeiger/cpm go 1.22.2 diff --git a/internal/testutil/test-utils.go b/internal/testutil/test-utils.go index 08c075e..33d16d5 100644 --- a/internal/testutil/test-utils.go +++ b/internal/testutil/test-utils.go @@ -2,7 +2,7 @@ package testutil import ( "github.com/spf13/afero" - "github.com/trgeiger/copr-tool/internal/app" + "github.com/trgeiger/cpm/internal/app" ) func AssembleTestFs(repoFiles [][]string, otherFiles [][]string) afero.Fs { diff --git a/main.go b/main.go index 66d37d2..35ab7da 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ package main import ( "github.com/spf13/afero" - "github.com/trgeiger/copr-tool/cmd" + "github.com/trgeiger/cpm/cmd" ) func main() {