1- // Copyright 2024 Jetify Inc. and contributors. All rights reserved.
1+ // Copyright 2025 Jetify Inc. and contributors. All rights reserved.
22// Use of this source code is governed by the license in the LICENSE file.
33
44package boxcli
@@ -15,7 +15,8 @@ import (
1515)
1616
1717type listCmdFlags struct {
18- config configFlags
18+ config configFlags
19+ outdated bool
1920}
2021
2122func listCmd () * cobra.Command {
@@ -34,6 +35,10 @@ func listCmd() *cobra.Command {
3435 return errors .WithStack (err )
3536 }
3637
38+ if flags .outdated {
39+ return outdatedPackage (cmd , box )
40+ }
41+
3742 for _ , pkg := range box .AllPackagesIncludingRemovedTriggerPackages () {
3843 resolvedVersion , err := pkg .ResolvedVersion ()
3944 if err != nil {
@@ -57,6 +62,28 @@ func listCmd() *cobra.Command {
5762 return nil
5863 },
5964 }
65+
66+ cmd .Flags ().BoolVar (& flags .outdated , "outdated" , false , "List outdated packages" )
6067 flags .config .register (cmd )
6168 return cmd
6269}
70+
71+ // outdatedPackage prints a list of outdated packages.
72+ func outdatedPackage (cmd * cobra.Command , box * devbox.Devbox ) error {
73+ results , err := box .Outdated (cmd .Context ())
74+ if err != nil {
75+ return errors .WithStack (err )
76+ }
77+
78+ if len (results ) == 0 {
79+ cmd .Println ("Your packages are up to date!" )
80+ return nil
81+ }
82+
83+ cmd .Println ("The following packages can be updated:" )
84+ for pkg , version := range results {
85+ cmd .Printf (" * %-30s %s -> %s\n " , pkg , version .Current , version .Latest )
86+ }
87+
88+ return nil
89+ }
0 commit comments