简体   繁体   中英

Vlang cli examples does not work in intuitive way

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 herevlang 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM