@@ -26,13 +26,15 @@ type driverDidUninstallMsg struct{}
2626type UninstallCmd struct {
2727 Driver string `arg:"positional,required" help:"Driver to uninstall"`
2828 Level config.ConfigLevel `arg:"-l" help:"Config level to uninstall from (user, system)"`
29+ Json bool `arg:"--json" help:"Print output as JSON instead of plaintext"`
2930}
3031
3132func (c UninstallCmd ) GetModelCustom (baseModel baseModel ) tea.Model {
3233 return uninstallModel {
33- baseModel : baseModel ,
34- Driver : c .Driver ,
35- cfg : getConfig (c .Level ),
34+ baseModel : baseModel ,
35+ Driver : c .Driver ,
36+ cfg : getConfig (c .Level ),
37+ jsonOutput : c .Json ,
3638 }
3739}
3840
@@ -42,16 +44,18 @@ func (c UninstallCmd) GetModel() tea.Model {
4244 getDriverRegistry : getDriverRegistry ,
4345 downloadPkg : downloadPkg ,
4446 },
45- Driver : c .Driver ,
46- cfg : getConfig (c .Level ),
47+ Driver : c .Driver ,
48+ cfg : getConfig (c .Level ),
49+ jsonOutput : c .Json ,
4750 }
4851}
4952
5053type uninstallModel struct {
5154 baseModel
5255
53- Driver string
54- cfg config.Config
56+ Driver string
57+ cfg config.Config
58+ jsonOutput bool
5559}
5660
5761func (m uninstallModel ) Init () tea.Cmd {
@@ -64,9 +68,15 @@ func (m uninstallModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
6468 case config.DriverInfo :
6569 return m .performUninstall (msg )
6670 case driverDidUninstallMsg :
71+ if m .jsonOutput {
72+ return m , tea .Sequence (tea .Printf ("{\" status\" : \" success\" , \" driver\" : \" %s\" }\n " , m .Driver ), tea .Quit )
73+ }
6774 return m , tea .Sequence (tea .Printf ("Driver `%s` uninstalled successfully!\n " , m .Driver ), tea .Quit )
6875 case error :
6976 m .status = 1
77+ if m .jsonOutput {
78+ return m , tea .Sequence (tea .Printf ("{\" status\" : \" error\" , \" error\" : \" %s\" }\n " , msg .Error ()), tea .Quit )
79+ }
7080 return m , tea .Sequence (
7181 tea .Println (errStyle .Render ("Error: " + msg .Error ())),
7282 tea .Quit )
0 commit comments