Vlang cli examples does not work in intuitive way - command-line
I have play bit a fun with vlang cli library, for the first touch, i come with playing from the examples directory of the v sources. You can see it in here vlang cli
i'm trying to grasp how to get the examples working. let's me show output the command i'm trying
$ v run ./examples/cli.v
Usage: cli [flags] [commands]
An example of the cli library.
Flags:
-help Prints help information.
-version Prints version information.
Commands:
greet Prints greeting in different languages.
help Prints help information.
version Prints version information.
green#ubuntu:~/Downloads/v$ v run ./examples/cli.v greet
Command `greet` needs at least 1 arguments
green#ubuntu:~/Downloads/v$ v run ./examples/cli.v greet painem
This is a function running before the main function.
Unsupported language
Supported languages are `english`, `german` and `dutch`.
cli execution error: ��|��
green#ubuntu:~/Downloads/v$ v run ./examples/cli.v greet painem --language english
This is a function running before the main function.
Unsupported language
Supported languages are `english`, `german` and `dutch`.
cli execution error: `u5��
green#ubuntu:~/Downloads/v$ v run ./examples/cli.v greet painem --language english --times 3 --fun a --fun b
This is a function running before the main function.
Unsupported language
Supported languages are `english`, `german` and `dutch`.
cli execution error: `B���
green#ubuntu:~/Downloads/v$ v run ./examples/cli.v greet --language english painem --times 3 --fun a --fun b
Flag `language` is required by `cli greet`
green#ubuntu:~/Downloads/v$ v run ./examples/cli.v greet --language german painem --times 3 --fun a --fun b
Flag `language` is required by `cli greet`
green#ubuntu:~/Downloads/v$ v run ./examples/cli.v greet --language='english' painem --times=3 --fun='a' --fun='b'
Flag `language` is required by `cli greet`
green#ubuntu:~/Downloads/v$ v run ./examples/cli.v greet painem --language='german' --times=3 --fun='a' --fun='b'
This is a function running before the main function.
Unsupported language
Supported languages are `english`, `german` and `dutch`.
cli execution error: #(��
green#ubuntu:~/Downloads/v$ v run ./examples/cli.v greet 'painem' --language='german' --times=3 --fun='a' --fun='b'
This is a function running before the main function.
Unsupported language
Supported languages are `english`, `german` and `dutch`.
cli execution error: �
green#ubuntu:~/Downloads/v$ v run ./examples/cli.v cli greet 'painem' --language='german'
This is a function running before the main function.
Unsupported language
Supported languages are `english`, `german` and `dutch`.
cli execution error: �j���
green#ubuntu:~/Downloads/v$ v run ./examples/cli.v greet --fun='blaj' --fun='blah' --times=3 'painem' --language='german'
This is a function running before the main function.
Unsupported language
Supported languages are `english`, `german` and `dutch`.
fun: blaj
fun: blah
This is a function running after the main function.
green#ubuntu:~/Downloads/v$ v run ./examples/cli.v greet --fun='blaj' --fun='blah' --times=3 'painem'
This is a function running before the main function.
Unsupported language
Supported languages are `english`, `german` and `dutch`.
fun: blaj
fun: blah
This is a function running after the main function.
green#ubuntu:~/Downloads/v$
I think i have passed the flag/option in the right way to the command.
What wrong with my step
Thanks for the help
Greenshirt
Is your V up-to-date ? I cannot reproduce this behavior. For example:
$ v run ./examples/cli.v greet painem
Flag `language` is required by `cli greet`
$ v run ./examples/cli.v greet --language english painem
This is a function running before the main function.
Welcome painem
Welcome painem
Welcome painem
This is a function running after the main function.
Which seems pretty correct to me.
If you're unsure whether your V is up-to-date or not (it probably isn't, since V update cycle is very very very short currently, multiple times a day), try to run v up. If it doesn't not work, you probably didn't install V the recommended way, which is by cloning the repository and installing it from source for now (https://github.com/vlang/v#installing-v-from-source).
greenshirt, try this:
v -x64 run cli.v --times=5 --language english 'How do you feel'
-x64-flag for Linux systems;
-g or -cg for MacOs;
Related
Runing mix new app_first failed on CentOS
I also encounter the problem: Runing mix new app_first failed in Elixir. It runs on centos. This is the message: The erlang version is normal : github#localhost:$ erl Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] The elixir version is normal github#localhost:~/elixir-otp-24$ bin/elixir --version Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] Elixir 1.14.0 (compiled with Erlang/OTP 24) But the mix is abnormal github#localhost:~/elixir-otp-24$ bin/mix {"init terminating in do_boot",{badarg,[{erlang,apply,[{'Elixir.Kernel.CLI.Config',[],<<".">>,[],true,[],[],false},update_commands,[#Fun<Elixir.Kernel.CLI.18.41400255>]],[{error_info,#{module=>erl_erts_errors}}]},{'Elixir.Kernel.CLI',process_argv,2,[{file,"lib/kernel/cli.ex"},{line,191}]},{'Elixir.Kernel.CLI',main,1,[{file,"lib/kernel/cli.ex"},{line,14}]},{init,start_em,1,[]},{init,do_boot,3,[]}]}} init terminating in do_boot ({badarg,[{erlang,apply,[{_},update_commands,[_]],[{_}]},{Elixir.Kernel.CLI,process_argv,2,[{_},{_}]},{Elixir.Kernel.CLI,main,1,[{_},{_}]},{init,start_em,1,[]},{init,do_boot,3,[]}]}) Crash dump is being written to: erl_crash.dump...done I have tried many ways, such as building from source. But it always failed.
I find the anwer: it should be setting environment variables. PATH=/data/github/elixir-otp-24/bin:$PATH Put it in .bashrc Source .bashrc It works github#localhost:~$ mix ** (Mix) "mix" with no arguments must be executed in a directory with a mix.exs file Usage: mix [task]
Change syntax of -k option in pytest 7.1.0 is not working with pytest_addoption(parser)
Below is my code which was working perfectly fine till I upgraded pytest to version 7.1.0 pytest.main(self.pytest_args + ["-k", tc_cfg.name, "--aq-cfg", tc_cfg.aq_cfg]) and in conftest, I have below code: def pytest_addoption(parser): parser.addoption("--aq-cfg", required=False) This was working fine for earlier pytest versions. With latest one(pytest 7.1.0) its failing with below error: ERROR: usage: aqueduct [options] [file_or_dir] [file_or_dir] [...] aqueduct: error: unrecognized arguments: --aq-cfg all_envs inifile: /home/aquser/dev/aqueduct/src/cb/test/tools/aqueduct/pytest.ini rootdir: /home/aquser/dev/aqueduct/src/cb/test/tools/aqueduct This is occurring because latest change added for -k syntax: https://docs.pytest.org/en/stable/changelog.html#pytest-7-1-0-2022-03-13 But if I try to remove --aq-cfg, its failing at pytest_adoption(parsar) and not able to locate file without "--". Any help on this would be appreciated!
How to fix "pytest: error: unrecognized arguments: -n"
Hi I am trying to run my tests parallely(pytest-xdist) on the azure pipelines. Till now the tests were running perfectly fine. Suddenly the pytest is throwing a weird error saying "unrecognized argument". The file name : integration_test.py Command used : pytest -n 5 --tb=short integration_test.py -v -s --> to run 5 tests parallely Total number of tests : 57 Versions : pytest==6.2.5 pytest-xdist==2.3.0 Even tried with the latest versions of these 2 modules. Error : ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...] pytest: error: unrecognized arguments: -n integration_test.py How can I overcome this error?
This error is what you encountered: As hoefling mentioned, the solution is to install the pytest-xdist: pip install pytest-xdist
On MacOS just running pytest might be ran by a different Python's version than you thought. $ pytest ============================================================================== test session starts =============================================================================== platform darwin -- Python 3.9.12, pytest-6.2.5, py-1.10.0, pluggy-0.13.1 rootdir: [REDACTED] plugins: anyio-3.5.0, cov-3.0.0 While $ python3 -m pytest ============================================================================== test session starts =============================================================================== platform darwin -- Python 3.10.6, pytest-7.1.2, pluggy-1.0.0 rootdir: [REDACTED] plugins: xdist-2.5.0, forked-1.4.0, pylama-8.4.1 Be careful, and launch it as a module :)
gcc is not Creating an Output File
The following command (via PowerShell in Windows 7) PS C:\Users\gvkv\projects\stats> C:\mingw\bin\gcc.exe .\lex.yy.c -o gmstats.exe -v output gives the following output gcc.exe: error: output: No such file or directory Using built-in specs. COLLECT_GCC=C:\mingw\bin\gcc.exe COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe Target: mingw32 Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32 --build=mingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto --enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gmp-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-libgomp --enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/mingw --disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T Thread model: win32 gcc version 4.8.1 (GCC) and I have no idea why. In particular, I don't understand the error at the top of the output. If I invoke gcc without the -v option: PS C:\Users\gvkv\projects\stats> C:\mingw\bin\gcc.exe .\lex.yy.c -o gmstats.exe I get: PS C:\Users\gvkv\projects\stats> Nominal success! This would be great if I also had gmstats.exe in my directory. Just for fun I've also tried running PowerShell as an administrator and I've also invoked gcc with an absolute path: PS ...>C:\MinGW\bin\gcc.exe just to make sure. I last used gcc to compile something (via make) and it worked fine. I also considered that there was a linker (ld.exe) problem but there's no file to link and the search directories are fine.
Error with PAR module
I have been trying to build .exe through PAR in windows XP and my perl version is 5.8.8.. I installed the latest PAR from PPM I gave the following command in the command prompt, C:\Documents and Settings\abc\Desktop\serial>pp -o serial.exe serial.pl Set up gcc environment - 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) Program too big to fit in memory Access is denied. Also it throws me the following error popup.. C:\DOCUME~1\abc\LOCALS~1\Temp\parlLoYJMpa.exe is not a valid Win32 application. Actually my script in just one line code.. I am confused... Please help me....
Worked fine for me, but then I use pp all the time with no problem. I didn't get any "Set up gcc environment..." message, no messages at all. I'm putting this as an answer because not enough room in the comment for all this: I did a gcc -v and got: C:\tools\perl\tests>gcc -v Reading specs from c:/Perl/site/lib/auto/MinGW/bin/../lib/gcc/mingw32/3.4.5/spec s Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug Thread model: win32 gcc version 3.4.5 (mingw-vista special r3)