Skip to content

Commit

Permalink
feat(cobra): Tentative sub-commands implementation
Browse files Browse the repository at this point in the history
Direct written operations to save or load Login Items.
5ouma committed Jan 15, 2024
1 parent 0f7a584 commit 4a15a15
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions cmd/load.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

@@ -18,6 +16,11 @@ func (c *Cmd) newLoadCmd() *cobra.Command {
}

func (c *Cmd) execLoadCmd(cmd *cobra.Command, args []string) error {
fmt.Println("a message from load")
if err := c.loginItems.Load("./login_item.json"); err != nil {
return err
}
if err := c.loginItems.Add(); err != nil {
return err
}
return nil
}
9 changes: 6 additions & 3 deletions cmd/save.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

@@ -18,6 +16,11 @@ func (c *Cmd) newSaveCmd() *cobra.Command {
}

func (c *Cmd) execSaveCmd(cmd *cobra.Command, args []string) error {
fmt.Println("a message from save")
if err := c.loginItems.Get(); err != nil {
return err
}
if err := c.loginItems.Save("./login_item.json", false); err != nil {
return err
}
return nil
}

0 comments on commit 4a15a15

Please sign in to comment.