mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v fmt: process .v files from a module too
This commit is contained in:

committed by
Alexander Medvednikov

parent
411a83e283
commit
96fa15c125
62
vlib/os/cmdline/cmdline.v
Normal file
62
vlib/os/cmdline/cmdline.v
Normal file
@@ -0,0 +1,62 @@
|
||||
module cmdline
|
||||
|
||||
pub fn many_values(args []string, optname string) []string {
|
||||
mut flags := []string
|
||||
for ci, cv in args {
|
||||
if cv == optname {
|
||||
if ci + 1 < args.len {
|
||||
flags << args[ci + 1]
|
||||
}
|
||||
}
|
||||
}
|
||||
return flags
|
||||
}
|
||||
|
||||
pub fn option(args []string, param string, def string) string {
|
||||
mut found := false
|
||||
for arg in args {
|
||||
if found {
|
||||
return arg
|
||||
}
|
||||
else if param == arg {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
pub fn before(args []string, what []string) []string {
|
||||
mut found := false
|
||||
mut args_before := []string
|
||||
for a in args {
|
||||
if a in what {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
args_before << a
|
||||
}
|
||||
return args_before
|
||||
}
|
||||
|
||||
pub fn after(args []string, what []string) []string {
|
||||
mut found := false
|
||||
mut args_after := []string
|
||||
for a in args {
|
||||
if a in what {
|
||||
found = true
|
||||
continue
|
||||
}
|
||||
if found {
|
||||
args_after << a
|
||||
}
|
||||
}
|
||||
return args_after
|
||||
}
|
||||
|
||||
pub fn only_non_options(args []string) []string {
|
||||
return args.filter(!it.starts_with('-'))
|
||||
}
|
||||
|
||||
pub fn only_options(args []string) []string {
|
||||
return args.filter(it.starts_with('-'))
|
||||
}
|
Reference in New Issue
Block a user