diff --git a/Commands/PullCommand.go b/Commands/PullCommand.go new file mode 100644 index 0000000..ad458a1 --- /dev/null +++ b/Commands/PullCommand.go @@ -0,0 +1,27 @@ +package Commands + +import ( + "fmt" + "github.com/urfave/cli/v2" + "log" +) + +func PullCommand() *cli.Command{ + return &cli.Command { + Name: "pull", + Usage: "Pull a package", + Description: "Pulls a package from the default registry server, or to a user-defined registry server.", + HelpName: "pull", + Action: func(c *cli.Context) error { + //Do Stuff + return nil + }, + OnUsageError: func(c *cli.Context, err error, isSubcommand bool) error { + if err != nil { + fmt.Printf("[ERROR] %s", err.Error()) + log.Fatal(err) + } + return err + }, + } +} diff --git a/Commands/PushCommand.go b/Commands/PushCommand.go new file mode 100644 index 0000000..e6e5c65 --- /dev/null +++ b/Commands/PushCommand.go @@ -0,0 +1,27 @@ +package Commands + +import ( + "fmt" + "github.com/urfave/cli/v2" + "log" +) + +func PushCommand() *cli.Command { + return &cli.Command { + Name: "push", + Usage: "Push a package", + Description: "Pushes a package to the default registry server, or to a user-defined registry server.", + HelpName: "push", + Action: func(c *cli.Context) error { + //Do Stuff + return nil + }, + OnUsageError: func(c *cli.Context, err error, isSubcommand bool) error { + if err != nil{ + fmt.Printf("[ERROR] %s", err.Error()) + log.Fatal(err) + } + return err + }, + } +} diff --git a/lpm-cli.go b/lpm-cli.go index 4a0f284..96409cc 100644 --- a/lpm-cli.go +++ b/lpm-cli.go @@ -1,56 +1,24 @@ package main import ( - "fmt" "github.com/urfave/cli/v2" "log" + "lpm-cli/Commands" + "lpm-cli/Informations" "os" - "lpm-cli/informations" ) func main(){ app := &cli.App { - Name: "lotus-pm", - Usage: "Lotus Package Manager", - Authors: informations.GetAuthors(), + Name: "lotus-pm", + Usage: "Lotus Package Manager", + Authors: Informations.GetAuthors(), Copyright: "(c) 2021 LPM-Group", Commands: []*cli.Command { - { - Name: "push", - Usage: "Push a package", - Description: "Pushes a package to the default registry server, or to a user-defined registry server.", - HelpName: "push", - Action: func(c *cli.Context) error { - //Do Stuff - return nil - }, - OnUsageError: func(c *cli.Context, err error, isSubcommand bool) error { - if err != nil{ - fmt.Printf("[ERROR] %s", err.Error()) - log.Fatal(err) - } - return err - }, - }, - { - Name: "pull", - Usage: "Pull a package", - Description: "Pulls a package from the default registry server, or to a user-defined registry server.", - HelpName: "pull", - Action: func(c *cli.Context) error { - //Do Stuff - return nil - }, - OnUsageError: func(c *cli.Context, err error, isSubcommand bool) error { - if err != nil { - fmt.Printf("[ERROR] %s", err.Error()) - log.Fatal(err) - } - return err - }, - }, + Commands.PushCommand(), + Commands.PullCommand(), }, }