-
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(check): New command to check Login Items are up-to-date (#50)
<!-- markdownlint-disable MD041 --> **Issue:** close #33 ### Checklist It returns an error if it's out-of-date. - [x] This Pull Request introduces a new feature. - [ ] This Pull Request fixes a bug. ### Description <!-- A clear and concise description - Why did you make this change? - Please describe how this method is better than others. --> <br /> - [x] I agree to follow the [Code of Conduct](https://github.com/5ouma/mli/blob/main/.github/CODE_OF_CONDUCT.md).
- Loading branch information
Showing
7 changed files
with
120 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Output .github/assets/vhs/dark/check.gif | ||
|
||
Require mli | ||
|
||
Set FontSize 40 | ||
Set Height 600 | ||
Set Width 1800 | ||
Set Theme { "background": "#161b22", "foreground": "#f4f4f4", "cursor": "#f4f4f4" } | ||
Set Padding 30 | ||
Set TypingSpeed 100ms | ||
|
||
Type "mli check --file='.github/assets/example/login_items.json'" | ||
Sleep 1s | ||
Enter | ||
Sleep 5s |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Output .github/assets/vhs/light/check.gif | ||
|
||
Require mli | ||
|
||
Set FontSize 40 | ||
Set Height 600 | ||
Set Width 1800 | ||
Set Theme { "background": "#f7f8fa", "foreground": "#242424", "cursor": "#242424" } | ||
Set Padding 30 | ||
Set TypingSpeed 100ms | ||
|
||
Type "mli check --file='.github/assets/example/login_items.json'" | ||
Sleep 1s | ||
Enter | ||
Sleep 5s |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"reflect" | ||
|
||
"github.com/5ouma/mli/lib" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func (cmd *cmd) newCheckCmd() *cobra.Command { | ||
checkCmd := &cobra.Command{ | ||
Use: "check", | ||
Short: "Check Login Items", | ||
Long: "π Check the Login Items are up-to-date", | ||
Args: cobra.NoArgs, | ||
RunE: cmd.execCheckCmd, | ||
} | ||
checkCmd.Flags().String("file", "./login_items.json", "Check Login Items from this JSON file") | ||
return checkCmd | ||
} | ||
|
||
func (cmd *cmd) execCheckCmd(command *cobra.Command, args []string) error { | ||
file, err := command.Flags().GetString("file") | ||
if err != nil { | ||
return err | ||
} | ||
path, err := filepath.Abs(file) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := cmd.loginItems.Load(path); err != nil { | ||
return err | ||
} | ||
loginItems := new(lib.LoginItems) | ||
if err := loginItems.Get(); err != nil { | ||
return err | ||
} | ||
if !reflect.DeepEqual(cmd.loginItems, loginItems) { | ||
return fmt.Errorf("login items are out-of-date") | ||
} | ||
fmt.Println("β Login Items are up-to-date!") | ||
|
||
return nil | ||
} |
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