mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
flag help message is now a bit more compact
This commit is contained in:
parent
482f4c1b6c
commit
49430a5c31
@ -416,8 +416,10 @@ pub fn (fs FlagParser) usage() string {
|
|||||||
if no_arguments { adesc = '' }
|
if no_arguments { adesc = '' }
|
||||||
|
|
||||||
mut use := ''
|
mut use := ''
|
||||||
|
if fs.application_version != '' {
|
||||||
use += '$fs.application_name $fs.application_version\n'
|
use += '$fs.application_name $fs.application_version\n'
|
||||||
use += '$UNDERLINE\n'
|
use += '$UNDERLINE\n'
|
||||||
|
}
|
||||||
use += 'Usage: ${fs.application_name} [options] $adesc\n'
|
use += 'Usage: ${fs.application_name} [options] $adesc\n'
|
||||||
use += '\n'
|
use += '\n'
|
||||||
if fs.application_description != '' {
|
if fs.application_description != '' {
|
||||||
@ -446,13 +448,22 @@ pub fn (fs FlagParser) usage() string {
|
|||||||
if fs.flags.len > 0 {
|
if fs.flags.len > 0 {
|
||||||
use += 'Options:\n'
|
use += 'Options:\n'
|
||||||
for f in fs.flags {
|
for f in fs.flags {
|
||||||
flag_desc := ' --$f.name $f.val_desc'
|
longstr := if f.val_desc.contains('bool') {
|
||||||
|
', --$f.name'
|
||||||
|
} else {
|
||||||
|
', --$f.name $f.val_desc'
|
||||||
|
}
|
||||||
|
flag_desc := if f.name.len == 0 {
|
||||||
|
', $f.val_desc'
|
||||||
|
} else {
|
||||||
|
longstr
|
||||||
|
}
|
||||||
space := if flag_desc.len > SPACE.len-2 {
|
space := if flag_desc.len > SPACE.len-2 {
|
||||||
'\n$SPACE'
|
'\n$SPACE'
|
||||||
} else {
|
} else {
|
||||||
SPACE[flag_desc.len..]
|
SPACE[flag_desc.len..]
|
||||||
}
|
}
|
||||||
abbr_desc := if f.abbr == `\0` { '' } else { ' -${tos(f.abbr, 1)}\n' }
|
abbr_desc := if f.abbr == `\0` { '' } else { ' -${tos(f.abbr, 1)}' }
|
||||||
use += '${abbr_desc}${flag_desc}${space}${f.usage}\n'
|
use += '${abbr_desc}${flag_desc}${space}${f.usage}\n'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user