-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cobra for cli parsing and remove kong (#42)
* feat: add cobra for cli parsing, change root and add commands to cobra * feat: switch build cmd to cobra * feat: switch init cmd to cobra * feat: switch logout cmd to cobra * feat: switch login cmd to cobra * feat: switch publish cmd to cobra * fix: format code of changed commands * fix: remove long usage of publish command * fix: remove non-used description in main.go and ditch Execute error * fix: remove unused struct previously used with kong * fix: run go mod tidy to remove kong from go.mod * feat: switch remove cmd to cobra * run go mod tidy * fix: run go mod tidy
- Loading branch information
Showing
11 changed files
with
417 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
package cmd | ||
|
||
import "github.com/c3pm-labs/c3pm/ctpm" | ||
import ( | ||
"github.com/c3pm-labs/c3pm/ctpm" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
//LogoutCmd defines the parameters of the logout command. | ||
type LogoutCmd struct{} | ||
|
||
//Run handles the behavior of the logout command. | ||
func (l *LogoutCmd) Run() error { | ||
return ctpm.Logout() | ||
var logoutCmd = &cobra.Command{ | ||
Use: "logout", | ||
Short: "Logout from the api", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return ctpm.Logout() | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
// Package cmd hosts the configuration and handling of the command line interface of C3PM. | ||
package cmd | ||
|
||
import "github.com/alecthomas/kong" | ||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
//CLI is the root configuration of C3PM's command line interface. | ||
var CLI struct { | ||
Version kong.VersionFlag `short:"v" help:"outputs the version number"` | ||
Add AddCmd `kong:"cmd,help='Add a new dependency'"` | ||
Remove RemoveCmd `kong:"cmd,help='Remove a dependency'"` | ||
Init InitCmd `kong:"cmd,help='Init a c3pm project'"` | ||
Logout LogoutCmd `kong:"cmd,help='Logout from the api'"` | ||
Login LoginCmd `kong:"cmd,help='Login to the api'"` | ||
Build BuildCmd `kong:"cmd,help='Build a c3pm project'"` | ||
Publish PublishCmd `kong:"cmd,help='Publish a c3pm project'"` | ||
var RootCmd = &cobra.Command{ | ||
Use: "ctpm", | ||
Short: "c3pm abstracts your build system and eases the management of your dependencies.", | ||
Long: "C3PM is a next-generation package manager for C++.\nYou can use C3PM to share and use packages with other developers around the world.", | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(addCmd) | ||
RootCmd.AddCommand(buildCmd) | ||
RootCmd.AddCommand(initCmd) | ||
RootCmd.AddCommand(logoutCmd) | ||
RootCmd.AddCommand(loginCmd) | ||
RootCmd.AddCommand(publishCmd) | ||
RootCmd.AddCommand(removeCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.