@@ -82,6 +82,11 @@ const cli = yargs
82
82
"additional git log arguments as space separated string, example '--first-parent --cherry-pick'" ,
83
83
type : 'string' ,
84
84
} ,
85
+ last : {
86
+ alias : 'l' ,
87
+ description : 'just analyze the last commit; applies if edit=false' ,
88
+ type : 'boolean' ,
89
+ } ,
85
90
format : {
86
91
alias : 'o' ,
87
92
description : 'output format of the results' ,
@@ -195,6 +200,19 @@ async function main(args: MainArgs): Promise<void> {
195
200
196
201
const fromStdin = checkFromStdin ( raw , flags ) ;
197
202
203
+ if (
204
+ Object . hasOwn ( flags , 'last' ) &&
205
+ ( Object . hasOwn ( flags , 'from' ) || Object . hasOwn ( flags , 'to' ) || flags . edit )
206
+ ) {
207
+ const err = new CliError (
208
+ 'Please use the --last flag alone. The --last flag should not be used with --to or --from or --edit.' ,
209
+ pkg . name
210
+ ) ;
211
+ yargs . showHelp ( 'log' ) ;
212
+ console . log ( err . message ) ;
213
+ throw err ;
214
+ }
215
+
198
216
const input = await ( fromStdin
199
217
? stdin ( )
200
218
: read ( {
@@ -212,7 +230,7 @@ async function main(args: MainArgs): Promise<void> {
212
230
213
231
if ( messages . length === 0 && ! checkFromRepository ( flags ) ) {
214
232
const err = new CliError (
215
- '[input] is required: supply via stdin, or --env or --edit or --from and --to' ,
233
+ '[input] is required: supply via stdin, or --env or --edit or --last or -- from and --to' ,
216
234
pkg . name
217
235
) ;
218
236
yargs . showHelp ( 'log' ) ;
@@ -355,7 +373,11 @@ function checkFromEdit(flags: CliFlags): boolean {
355
373
}
356
374
357
375
function checkFromHistory ( flags : CliFlags ) : boolean {
358
- return typeof flags . from === 'string' || typeof flags . to === 'string' ;
376
+ return (
377
+ typeof flags . from === 'string' ||
378
+ typeof flags . to === 'string' ||
379
+ typeof flags . last === 'boolean'
380
+ ) ;
359
381
}
360
382
361
383
function normalizeFlags ( flags : CliFlags ) : CliFlags {
0 commit comments