v/vlib/cli
2025-07-02 15:45:47 +03:00
..
testdata cli: fix default flags when their command equivalents are disabled (#21469) 2024-05-08 14:11:40 +03:00
cli_test.v cli: fix default flags when their command equivalents are disabled (#21469) 2024-05-08 14:11:40 +03:00
command.v docs: use cmd/tools/find_doc_comments_with_no_dots.v to put some missing dots in the doc comments of public symbols. 2025-07-02 15:45:47 +03:00
command_test.v fmt: fix alignment of struct init fields (#22025) 2024-08-11 09:11:24 +03:00
flag.v docs: use cmd/tools/find_doc_comments_with_no_dots.v to put some missing dots in the doc comments of public symbols. 2025-07-02 15:45:47 +03:00
flag_test.v fmt: fix alignment of struct init fields (#22025) 2024-08-11 09:11:24 +03:00
help.v cli: account for initial indent on subcommands (#23985) 2025-03-20 13:33:27 +02:00
help_test.v fmt: fix formating a file in an oscillating manner (fix #22223, fix #22026) (#22232) 2024-09-17 09:47:38 +03:00
man.v docs: use cmd/tools/find_doc_comments_with_no_dots.v to put some missing dots in the doc comments of public symbols. 2025-07-02 15:45:47 +03:00
man_test.v fmt: fix formating a file in an oscillating manner (fix #22223, fix #22026) (#22232) 2024-09-17 09:47:38 +03:00
README.md cli: fix minor typo (#23811) 2025-02-26 09:04:39 +02:00
version.v v: remove the automatic passing of structs with more than 8 fields by reference (related #17159) (#22547) 2024-10-17 11:04:23 +03:00

Description

cli is a command line option parser, that supports declarative subcommands, each having a separate set of options.

See also the flag module, for a simpler command line option parser, that supports only options.

Example

module main

import os
import cli

fn main() {
	mut app := cli.Command{
		name:        'example-app'
		description: 'example-app'
		execute:     fn (cmd cli.Command) ! {
			println('hello app')
			return
		}
		commands:    [
			cli.Command{
				name:    'sub'
				execute: fn (cmd cli.Command) ! {
					println('hello subcommand')
					return
				}
			},
		]
	}
	app.setup()
	app.parse(os.args)
}