File tree Expand file tree Collapse file tree 13 files changed +167
-144
lines changed Expand file tree Collapse file tree 13 files changed +167
-144
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ package install
2
+
3
+ import (
4
+ "fmt"
5
+ "strconv"
6
+ "strings"
7
+
8
+ "github.com/spf13/cobra"
9
+ )
10
+
11
+ // Register registers install command.
12
+ func Register (root * cobra.Command ) {
13
+ cmd := & cobra.Command {
14
+ Use : "install [name of packages]" ,
15
+ Aliases : []string {"i" },
16
+ Short : "installs a package" ,
17
+ Long : "Installing package(s) in DonyaOS" ,
18
+ Args : cobra .MinimumNArgs (1 ),
19
+ Run : func (cmd * cobra.Command , args []string ) {
20
+ leng := strconv .Itoa (len (args ))
21
+ fmt .Println ("Installing " + leng + " package(s): " + strings .Join (args , " " ))
22
+ },
23
+ }
24
+
25
+ root .AddCommand (cmd )
26
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ package purge
2
+
3
+ import (
4
+ "fmt"
5
+ "strconv"
6
+ "strings"
7
+
8
+ "github.com/spf13/cobra"
9
+ )
10
+
11
+ // Register registers purge command.
12
+ func Register (root * cobra.Command ) {
13
+ cmd := & cobra.Command {
14
+ Use : "purge [name of packages]" ,
15
+ Aliases : []string {"p" },
16
+ Short : "removes all orphaned packages" ,
17
+ Long : "Removing all orphaned package(s) in DonyaOS" ,
18
+ Args : cobra .MinimumNArgs (1 ),
19
+ Run : func (cmd * cobra.Command , args []string ) {
20
+ leng := strconv .Itoa (len (args ))
21
+ fmt .Println ("Purging " + leng + " package(s): " + strings .Join (args , " " ))
22
+ },
23
+ }
24
+
25
+ root .AddCommand (cmd )
26
+ }
Original file line number Diff line number Diff line change @@ -4,22 +4,29 @@ import (
4
4
"fmt"
5
5
"os"
6
6
7
+ "github.com/DonyaOS/PackageManager/cmd/install"
8
+ "github.com/DonyaOS/PackageManager/cmd/purge"
9
+ "github.com/DonyaOS/PackageManager/cmd/search"
7
10
"github.com/spf13/cobra"
8
11
)
9
12
10
- var cfgFile string
11
-
12
- // rootCmd represents the base command when called without any subcommands
13
- var rootCmd = & cobra.Command {
14
- Use : "todo" ,
15
- Short : "A simple todo list made with golan" ,
16
- }
13
+ // ExitFailure status code.
14
+ const ExitFailure = 1
17
15
18
16
// Execute adds all child commands to the root command and sets flags appropriately.
19
17
// This is called by main.main(). It only needs to happen once to the rootCmd.
20
18
func Execute () {
21
- if err := rootCmd .Execute (); err != nil {
22
- fmt .Println (err )
23
- os .Exit (1 )
19
+ root := & cobra.Command {
20
+ Use : "donya" ,
21
+ Short : "Donya Package Manager/System" ,
22
+ }
23
+
24
+ install .Register (root )
25
+ purge .Register (root )
26
+ search .Register (root )
27
+
28
+ if err := root .Execute (); err != nil {
29
+ fmt .Printf ("error: %s\n " , err .Error ())
30
+ os .Exit (ExitFailure )
24
31
}
25
32
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ package search
2
+
3
+ import (
4
+ "fmt"
5
+ "strconv"
6
+ "strings"
7
+
8
+ "github.com/spf13/cobra"
9
+ )
10
+
11
+ // Register registers search command.
12
+ func Register (root * cobra.Command ) {
13
+ cmd := & cobra.Command {
14
+ Use : "search [name of packages]" ,
15
+ Aliases : []string {"s" },
16
+ Short : "searches for a package" ,
17
+ Long : "Searching for a package(s) in DonyaOS" ,
18
+ Args : cobra .MinimumNArgs (1 ),
19
+ Run : func (cmd * cobra.Command , args []string ) {
20
+ leng := strconv .Itoa (len (args ))
21
+ fmt .Println ("Searching for " + leng + " package(s): " + strings .Join (args , " " ))
22
+ },
23
+ }
24
+
25
+ root .AddCommand (cmd )
26
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ package cmd
2
+
3
+ import (
4
+ "fmt"
5
+ "strconv"
6
+ "strings"
7
+
8
+ "github.com/spf13/cobra"
9
+ )
10
+
11
+ // Register registers uninstall command.
12
+ func Register (root * cobra.Command ) {
13
+ cmd := & cobra.Command {
14
+ Use : "uninstall [name of packages]" ,
15
+ Aliases : []string {"r" , "remove" },
16
+ Short : "removes a package" ,
17
+ Long : "Removing package(s) in DonyaOS" ,
18
+ Args : cobra .MinimumNArgs (1 ),
19
+ Run : func (cmd * cobra.Command , args []string ) {
20
+ leng := strconv .Itoa (len (args ))
21
+ fmt .Println ("Uninstalling " + leng + " package(s): " + strings .Join (args , " " ))
22
+ },
23
+ }
24
+
25
+ root .AddCommand (cmd )
26
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments