Skip to content

Commit a045bb0

Browse files
committed
all: use arguments() instead of os.args in some files
1 parent 0dd7698 commit a045bb0

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

cmd/tools/fast/fast.v

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import time
66
import arrays
77
import log
88

9+
const args = arguments()
910
const warmup_samples = 2
1011

1112
const max_samples = 20
@@ -54,7 +55,7 @@ fn main() {
5455
if vdir.contains('/tmp/cirrus-ci-build') {
5556
ccompiler_path = 'clang'
5657
}
57-
if os.args.contains('-clang') {
58+
if args.contains('-clang') {
5859
ccompiler_path = 'clang'
5960
}
6061
elog('fast_dir: ${fast_dir} | vdir: ${vdir} | compiler: ${ccompiler_path}')
@@ -68,7 +69,7 @@ fn main() {
6869
os.create('table.html')!
6970
}
7071

71-
if !os.args.contains('-noupdate') {
72+
if !args.contains('-noupdate') {
7273
elog('Fetching updates...')
7374
ret := lsystem('${vdir}/v up')
7475
if ret != 0 {
@@ -83,7 +84,7 @@ fn main() {
8384
uploaded_index := os.read_file('fast.vlang.io/index.html')!
8485
if uploaded_index.contains('>${commit}<') {
8586
elog('NOTE: commit ${commit} had been benchmarked already.')
86-
if !os.args.contains('-force') {
87+
if !args.contains('-force') {
8788
elog('nothing more to do')
8889
return
8990
}
@@ -98,21 +99,21 @@ fn main() {
9899
elog('Benchmarking commit ${commit} , with commit message: "${message}", commit_date: ${commit_date}, date: ${date}')
99100

100101
// build an optimized V
101-
if os.args.contains('-do-not-rebuild-vprod') {
102+
if args.contains('-do-not-rebuild-vprod') {
102103
if !os.exists('vprod') {
103104
elog('Exiting, since if you use `-do-not-rebuild-vprod`, you should already have a `${vdir}/vprod` executable, but it is missing!')
104105
return
105106
}
106107
} else {
107108
elog(' Building vprod...')
108-
if os.args.contains('-noprod') {
109+
if args.contains('-noprod') {
109110
lexec('./v -o vprod cmd/v') // for faster debugging
110111
} else {
111112
lexec('./v -o vprod -prod -prealloc cmd/v')
112113
}
113114
}
114115

115-
if !os.args.contains('-do-not-rebuild-caches') {
116+
if !args.contains('-do-not-rebuild-caches') {
116117
elog('clearing caches...')
117118
// cache vlib modules
118119
lexec('${vdir}/v wipe-cache')
@@ -163,7 +164,7 @@ fn main() {
163164
res.close()
164165

165166
// upload the result to github pages
166-
if os.args.contains('-upload') {
167+
if args.contains('-upload') {
167168
$if freebsd {
168169
// Note: tcc currently can not compile vpm on FreeBSD, due to its dependence on net.ssl and net.mbedtls, so force using clang instead:
169170
elog('FreeBSD: compiling the VPM tool with clang...')

cmd/tools/vself.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import os
44
import os.cmdline
55
import v.util.recompilation
66

7-
const is_debug = os.args.contains('-debug')
7+
const args_ = arguments()
8+
const is_debug = args_.contains('-debug')
89

910
// support a renamed `v` executable too:
1011
const vexe = os.getenv_opt('VEXE') or { @VEXE }
@@ -24,7 +25,7 @@ fn main() {
2425
recompilation.must_be_enabled(vroot, 'Please install V from source, to use `${vexe_name} self` .')
2526
os.chdir(vroot)!
2627
os.setenv('VCOLORS', 'always', true)
27-
mut args := os.args[1..].filter(it != 'self')
28+
mut args := args_[1..].filter(it != 'self')
2829
if args.len == 0 || ('-cc' !in args && '-prod' !in args && '-parallel-cc' !in args) {
2930
// compiling by default, i.e. `v self`:
3031
uos := os.user_os()

cmd/tools/vup.v

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ struct App {
1818
skip_current bool // skip the current hash check, enabling easier testing on the same commit, without using docker etc
1919
}
2020

21+
const args = arguments()
22+
2123
fn new_app() App {
2224
return App{
23-
is_verbose: '-v' in os.args
24-
is_prod: '-prod' in os.args
25+
is_verbose: '-v' in args
26+
is_prod: '-prod' in args
2527
vexe: vexe
2628
vroot: vroot
27-
skip_v_self: '-skip_v_self' in os.args
28-
skip_current: '-skip_current' in os.args
29+
skip_v_self: '-skip_v_self' in args
30+
skip_current: '-skip_current' in args
2931
}
3032
}
3133

examples/fibonacci.v

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
// This program displays the fibonacci sequence
2-
import os
2+
const args = arguments()
33

44
fn main() {
55
// Check for user input
6-
if os.args.len != 2 {
6+
if args.len != 2 {
77
println('usage: fibonacci [rank]')
8-
98
return
109
}
11-
1210
// Parse first argument and cast it to int
13-
14-
stop := os.args[1].int()
11+
stop := args[1].int()
1512
// Can only calculate correctly until rank 92
1613
if stop > 92 {
1714
println('rank must be 92 or less')
1815
return
1916
}
20-
2117
// Three consecutive terms of the sequence
2218
mut a := i64(0)
2319
mut b := i64(0)
@@ -29,7 +25,6 @@ fn main() {
2925
b = c
3026
// Compute the new term
3127
c = a + b
32-
3328
// Print the new term
3429
println(c)
3530
}

0 commit comments

Comments
 (0)