@@ -17,6 +17,12 @@ import (
1717const (
1818 flagRepoPath = "repo"
1919 flagIgnoreExistsTag = "ignore-exists-tag"
20+ flagFormat = "format"
21+ )
22+
23+ const (
24+ formatFull = "full"
25+ formatTagOnly = "tag"
2026)
2127
2228var (
@@ -81,8 +87,18 @@ func main() {
8187 {
8288 Name : "last" ,
8389 Aliases : []string {"l" },
84- Action : withManager (cmdTagGetSemverLast ),
85- Usage : "show last semver tag" ,
90+ Flags : []cli.Flag {
91+ & cli.StringFlag {
92+ Name : flagFormat ,
93+ Usage : "will change the output format" ,
94+ Value : formatFull ,
95+ Aliases : []string {"f" },
96+ OnlyOnce : true ,
97+ Required : false ,
98+ },
99+ },
100+ Action : withManager (cmdTagGetSemverLast ),
101+ Usage : "show last semver tag" ,
86102 },
87103 },
88104 },
@@ -176,12 +192,25 @@ func buildTagIncrementor(component repomanager.Component) func(context.Context,
176192}
177193
178194func cmdTagGetSemverLast (ctx context.Context , c * cli.Command , m * repomanager.Manager ) error {
195+ format := c .String (flagFormat )
196+ switch format {
197+ default :
198+ return fmt .Errorf ("unknown format: %s" , format )
199+ case formatFull , formatTagOnly :
200+ }
201+
179202 maxTag , err := m .GetTagsSemverMax ()
180203 if err != nil {
181204 return fmt .Errorf ("cannot get max tag: %w" , err )
182205 }
183206
184- fmt .Printf ("%s (%s)\n " , maxTag .TagName (), maxTag .Ref .Hash ())
207+ switch format {
208+ case formatFull :
209+ fmt .Printf ("%s (%s)\n " , maxTag .TagName (), maxTag .Ref .Hash ())
210+ case formatTagOnly :
211+ fmt .Printf ("%s\n " , maxTag .TagName ())
212+ }
213+
185214 return nil
186215}
187216
0 commit comments