@@ -2,11 +2,13 @@ package cmd
22
33import (
44 "github.com/rsteube/carapace"
5+ "github.com/rsteube/carapace-bin/pkg/actions/tools/jj"
6+ "github.com/rsteube/carapace-bridge/pkg/actions/bridge"
57 "github.com/spf13/cobra"
68)
79
810var interdiffCmd = & cobra.Command {
9- Use : "interdiff" ,
11+ Use : "interdiff [OPTIONS] <--from <FROM>|--to <TO>> [PATHS].. " ,
1012 Short : "Compare the changes of two commits" ,
1113 Run : func (cmd * cobra.Command , args []string ) {},
1214}
@@ -15,13 +17,28 @@ func init() {
1517 carapace .Gen (interdiffCmd ).Standalone ()
1618
1719 interdiffCmd .Flags ().Bool ("color-words" , false , "Show a word-level diff with changes indicated only by color" )
18- interdiffCmd .Flags ().String ("from" , "" , "Show changes from this revision" )
20+ interdiffCmd .Flags ().String ("from" , "@ " , "Show changes from this revision" )
1921 interdiffCmd .Flags ().Bool ("git" , false , "Show a Git-format diff" )
2022 interdiffCmd .Flags ().BoolP ("help" , "h" , false , "Print help (see more with '--help')" )
2123 interdiffCmd .Flags ().Bool ("stat" , false , "Show a histogram of the changes" )
2224 interdiffCmd .Flags ().BoolP ("summary" , "s" , false , "For each path, show only whether it was modified, added, or removed" )
23- interdiffCmd .Flags ().String ("to" , "" , "Show changes to this revision" )
25+ interdiffCmd .Flags ().String ("to" , "@ " , "Show changes to this revision" )
2426 interdiffCmd .Flags ().String ("tool" , "" , "Generate diff by external command" )
2527 interdiffCmd .Flags ().Bool ("types" , false , "For each path, show only its type before and after" )
2628 rootCmd .AddCommand (interdiffCmd )
29+
30+ carapace .Gen (interdiffCmd ).FlagCompletion (carapace.ActionMap {
31+ "from" : jj .ActionRevs (jj.RevOption {}.Default ()),
32+ "to" : jj .ActionRevs (jj.RevOption {}.Default ()),
33+ "tool" : bridge .ActionCarapaceBin ().Split (),
34+ })
35+
36+ carapace .Gen (interdiffCmd ).PositionalAnyCompletion (
37+ carapace .ActionCallback (func (c carapace.Context ) carapace.Action {
38+ return jj .ActionRevDiffs (
39+ interdiffCmd .Flag ("from" ).Value .String (),
40+ interdiffCmd .Flag ("to" ).Value .String (),
41+ ).FilterArgs ()
42+ }),
43+ )
2744}
0 commit comments