@@ -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,21 @@ async function main(args: MainArgs): Promise<void> {
195
200
196
201
const fromStdin = checkFromStdin ( raw , flags ) ;
197
202
203
+ if (
204
+ typeof flags . last !== 'undefined' &&
205
+ ( typeof flags . from !== 'undefined' ||
206
+ typeof flags . to !== 'undefined' ||
207
+ typeof flags . edit !== 'undefined' )
208
+ ) {
209
+ const err = new CliError (
210
+ 'Please use the --last flag alone. The --last flag should not be used with --to or --from or --edit.' ,
211
+ pkg . name
212
+ ) ;
213
+ yargs . showHelp ( 'log' ) ;
214
+ console . log ( err . message ) ;
215
+ throw err ;
216
+ }
217
+
198
218
const input = await ( fromStdin
199
219
? stdin ( )
200
220
: read ( {
@@ -212,7 +232,7 @@ async function main(args: MainArgs): Promise<void> {
212
232
213
233
if ( messages . length === 0 && ! checkFromRepository ( flags ) ) {
214
234
const err = new CliError (
215
- '[input] is required: supply via stdin, or --env or --edit or --from and --to' ,
235
+ '[input] is required: supply via stdin, or --env or --edit or --last or -- from and --to' ,
216
236
pkg . name
217
237
) ;
218
238
yargs . showHelp ( 'log' ) ;
@@ -355,7 +375,11 @@ function checkFromEdit(flags: CliFlags): boolean {
355
375
}
356
376
357
377
function checkFromHistory ( flags : CliFlags ) : boolean {
358
- return typeof flags . from === 'string' || typeof flags . to === 'string' ;
378
+ return (
379
+ typeof flags . from === 'string' ||
380
+ typeof flags . to === 'string' ||
381
+ typeof flags . last === 'boolean'
382
+ ) ;
359
383
}
360
384
361
385
function normalizeFlags ( flags : CliFlags ) : CliFlags {
0 commit comments