diff --git a/.github/README.md b/.github/README.md
index c93f6c0..c88e3be 100644
--- a/.github/README.md
+++ b/.github/README.md
@@ -62,6 +62,7 @@ Usage:
mli [command]
Available Commands:
+ check Check Login Items
help Help about any command
load Load Login Items
save Save Login Items
@@ -101,7 +102,7 @@ Use "mli [command] --help" for more information about a command.
media="(prefers-color-scheme: dark)"
/>
-
+
@@ -132,7 +133,35 @@ Use "mli [command] --help" for more information about a command.
media="(prefers-color-scheme: dark)"
/>
-
+
+
+
+
+- ### 🔍 `Check`
+
+ ```shell
+ 🔍 Check the Login Items are up-to-date
+
+ Usage:
+ mli check [flags]
+
+ Flags:
+ --file string Check Login Items from this JSON file (default "./login_items.json")
+ -h, --help help for check
+ ```
+
+
+
+
+
+
+
diff --git a/.github/assets/vhs/dark/check.tape b/.github/assets/vhs/dark/check.tape
new file mode 100644
index 0000000..2718050
--- /dev/null
+++ b/.github/assets/vhs/dark/check.tape
@@ -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
diff --git a/.github/assets/vhs/light/check.tape b/.github/assets/vhs/light/check.tape
new file mode 100644
index 0000000..4bb38d0
--- /dev/null
+++ b/.github/assets/vhs/light/check.tape
@@ -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
diff --git a/.github/assets/vhs/light/load.tape b/.github/assets/vhs/light/load.tape
index 5b975a4..d79775c 100644
--- a/.github/assets/vhs/light/load.tape
+++ b/.github/assets/vhs/light/load.tape
@@ -7,7 +7,7 @@ Set Height 600
Set Width 1800
Set Theme { "background": "#f7f8fa", "foreground": "#242424", "cursor": "#242424" }
Set Padding 30
-Set TypingSpeed 80ms
+Set TypingSpeed 100ms
Type "mli load --file='.github/assets/example/login_items.json'"
Sleep 1s
diff --git a/.github/workflows/vhs.yml b/.github/workflows/vhs.yml
index 7659cb9..e9df4b2 100644
--- a/.github/workflows/vhs.yml
+++ b/.github/workflows/vhs.yml
@@ -41,6 +41,11 @@ jobs:
with:
path: ".github/assets/vhs/light/save.tape"
+ - name: ☀️ Record Light Check Tape
+ uses: charmbracelet/vhs-action@v2
+ with:
+ path: ".github/assets/vhs/light/check.tape"
+
- name: 🌕 Record Dark Load Tape
uses: charmbracelet/vhs-action@v2
with:
@@ -51,6 +56,11 @@ jobs:
with:
path: ".github/assets/vhs/dark/save.tape"
+ - name: 🌕 Record Dark Check Tape
+ uses: charmbracelet/vhs-action@v2
+ with:
+ path: ".github/assets/vhs/dark/check.tape"
+
- name: 🎈 Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
diff --git a/cmd/check.go b/cmd/check.go
new file mode 100644
index 0000000..3b2d8e1
--- /dev/null
+++ b/cmd/check.go
@@ -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
+}
diff --git a/cmd/command.go b/cmd/command.go
index e09d2f0..ce58fb4 100644
--- a/cmd/command.go
+++ b/cmd/command.go
@@ -25,6 +25,7 @@ func New() *cmd {
cmd.command.SetVersionTemplate("📑 {{.Use}} {{.Version}}\n")
cmd.command.SetErrPrefix("🚨")
cmd.command.AddCommand(
+ cmd.newCheckCmd(),
cmd.newLoadCmd(),
cmd.newSaveCmd(),
)