Skip to content

Commit b92b02e

Browse files
committed
refactor(root): make watch flag default
- introduce a static flag to not use hot reloading instead
1 parent 4d9cebe commit b92b02e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

cmd/root.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import (
1717
)
1818

1919
var (
20-
watch bool
20+
static bool
2121
configPath string
2222
)
2323

2424
func init() {
25-
rootCmd.Flags().BoolVarP(&watch, "watch", "w", false, "Watch for changes in the input file")
25+
rootCmd.Flags().BoolVarP(&static, "static", "s", false, "Disable live reload (watch mode is enabled by default)")
2626
rootCmd.Flags().StringVarP(&configPath, "config", "c", "", "Path to config file")
2727
rootCmd.AddCommand(versionCmd)
2828
}
@@ -39,6 +39,9 @@ var rootCmd = &cobra.Command{
3939
}
4040
return nil
4141
},
42+
CompletionOptions: cobra.CompletionOptions{
43+
DisableDefaultCmd: true,
44+
},
4245
RunE: func(cmd *cobra.Command, args []string) error {
4346
if err := config.Load(configPath); err != nil {
4447
return err
@@ -58,7 +61,7 @@ var rootCmd = &cobra.Command{
5861

5962
p := tea.NewProgram(tui.New(root), tea.WithAltScreen(), tea.WithMouseAllMotion())
6063

61-
if watch {
64+
if !static {
6265
watcher, err := fsnotify.NewWatcher()
6366
if err != nil {
6467
p.Send(tui.UpdateSlidesMsg{NewRoot: createErrorSlide(err, "none")})

0 commit comments

Comments
 (0)