sapling/eden/scm/tests/test-subcommands.t

279 lines
7.6 KiB
Perl
Raw Normal View History

#chg-compatible
$ newext testcommands <<EOF
> from edenscm.mercurial import registrar
> cmdtable = {}
> command = registrar.command(cmdtable)
> @command('test', [], 'hg test SUBCOMMAND', subonly=True)
> def test(ui, repo):
> """test command"""
> ui.status("test command called (should not happen)\n")
> subcmd = test.subcommand(categories=[("First Category", ["one"])])
> @subcmd('one', [])
> def testone(ui, repo):
> """first test subcommand"""
> ui.status("test subcommand one called\n")
> @subcmd('two', [])
> def testone(ui, repo):
> """second test subcommand"""
> ui.status("test subcommand two called\n")
> @command('othertest', [], 'hg othertest [SUBCOMMAND]')
> def othertest(ui, repo, parameter):
> """other test command"""
> ui.status("other test command called with '%s'\n" % parameter)
> othersubcmd = othertest.subcommand()
> @othersubcmd('alpha|alfa', [])
> def othertestalpha(ui, repo, parameter):
> """other test subcommand alpha"""
> ui.status("other test command alpha called with '%s'\n" % parameter)
> nestedsubcmd = othertestalpha.subcommand()
> @nestedsubcmd('beta', [])
> def othertestalphabeta(ui, repo):
> """other test subcommand alpha subcommand beta"""
> ui.status("other test command alpha/beta called\n")
> EOF
$ readconfig <<EOF
> [alias]
> xt = test
> xt1 = test one
> xt0 = test nonexistent
> yt = othertest
> yta = othertest alpha
> ytf = othertest foo
> EOF
$ hg init
$ hg test
hg test: subcommand required
[255]
$ hg test one
test subcommand one called
$ hg test two
test subcommand two called
$ hg test nonexistent
hg test: unknown subcommand 'nonexistent'
[255]
$ hg tes o
unknown command 'tes'
(use 'hg help' to get help)
[255]
$ hg xt
hg test: subcommand required
[255]
$ hg xt one
test subcommand one called
$ hg xt too
hg test: unknown subcommand 'too'
[255]
$ hg xt1
test subcommand one called
$ hg xt0
hg test: unknown subcommand 'nonexistent'
[255]
$ hg othertest
hg othertest: invalid arguments
(use 'hg othertest -h' to get help)
[255]
$ hg othertest foo
other test command called with 'foo'
$ hg othertest alpha
hg othertest alpha: invalid arguments
(use 'hg othertest alpha -h' to get help)
[255]
$ hg othertest alfa foo
other test command alpha called with 'foo'
$ hg othertest alpha beta
other test command alpha/beta called
$ hg yt
hg othertest: invalid arguments
(use 'hg othertest -h' to get help)
[255]
$ hg yta foo
other test command alpha called with 'foo'
$ hg ytf
other test command called with 'foo'
$ hg help test
hg test SUBCOMMAND
test command
First Category:
one first test subcommand
Other Subcommands:
two second test subcommand
(use 'hg help test SUBCOMMAND' to show complete subcommand help)
(some details hidden, use --verbose to show complete help)
$ hg help test --quiet
hg test SUBCOMMAND
test command
First Category:
one first test subcommand
Other Subcommands:
two second test subcommand
$ hg help test one
hg test one
first test subcommand
(some details hidden, use --verbose to show complete help)
$ hg help test one --quiet
hg test one
first test subcommand
$ hg help test two --verbose
hg test two
second test subcommand
Global options ([+] can be repeated):
encoding: use correct output encoding on windows Summary: On Windows, there are *two* 8-bit encodings for each process. * The ANSI code page is used for all `...A` system calls, and this is what Mercurial uses internally. It can be overridden using the `--encoding` command line option. * The OEM code page is used when outputing to the console. Mercurial has no concept of this, and instead renders to the console using the ANSI code page, which results in mojibake like "Θ" instead of "é". Add the concept of an `outputencoding`. If this differs from `encoding`, we convert from the local encoding to the output encoding before writing to the console. On non-Windows platforms, this defaults to the same encoding as the local encoding, so this is a no-op unless `--outputencoding` is manually specified. On Windows, this defaults to the codepage given by `GetOEMCP`, causing output to be converted to the OEM codepage before being printed. For ordinary strings, the local encoded version is wrapped by `localstr` if the encoding does not round-trip cleanly. This means the output encoding works even if the character is not represented in the local encoding. Unfortunately, the templater is not localstr-clean, which means strings can get flattened down to the local encoding and the original code points are lost. In this case we can only output characters which are in the intersection of the encoding and the output encoding. Most US English Windows systems use cp1252 for the ANSI code page and cp437 for the OEM code page. These both contain many accented characters, so users with accented characters in their names will now see them correctly rendered. All of this only applies to Python 2.7. In Python 3, everything is Unicode, the `--encoding` and `--outputencoding` options do nothing, and it just works. Reviewed By: quark-zju, ikostia Differential Revision: D19951381 fbshipit-source-id: d5cb8b5bfe2bc131b2e6c3b892137a48b2139ca9
2020-02-20 15:27:06 +03:00
-R --repository REPO repository root directory or name of overlay
bundle file
--cwd DIR change working directory
-y --noninteractive do not prompt, automatically pick the first choice
for all prompts
-q --quiet suppress output
-v --verbose enable additional output
--color TYPE when to colorize (boolean, always, auto, never, or
debug)
--config CONFIG [+] set/override config option (use
'section.name=value')
--configfile FILE [+] enables the given config file
--debug enable debugging output
--debugger start debugger
--encoding ENCODE set the charset encoding (default: utf-8)
--encodingmode MODE set the charset encoding mode (default: strict)
--outputencoding ENCODE set the output encoding (default: utf-8)
--traceback always print a traceback on exception
--time time how long the command takes
--profile print command execution profile
--version output version information and exit
-h --help display help and exit
--hidden consider hidden changesets
--pager TYPE when to paginate (boolean, always, auto, or never)
(default: auto)
$ hg help test nonexistent
abort: 'test' has no such subcommand: nonexistent
(run 'hg help test' to see available subcommands)
[255]
$ hg othertest --help --verbose
hg othertest [SUBCOMMAND]
other test command
Global options ([+] can be repeated):
encoding: use correct output encoding on windows Summary: On Windows, there are *two* 8-bit encodings for each process. * The ANSI code page is used for all `...A` system calls, and this is what Mercurial uses internally. It can be overridden using the `--encoding` command line option. * The OEM code page is used when outputing to the console. Mercurial has no concept of this, and instead renders to the console using the ANSI code page, which results in mojibake like "Θ" instead of "é". Add the concept of an `outputencoding`. If this differs from `encoding`, we convert from the local encoding to the output encoding before writing to the console. On non-Windows platforms, this defaults to the same encoding as the local encoding, so this is a no-op unless `--outputencoding` is manually specified. On Windows, this defaults to the codepage given by `GetOEMCP`, causing output to be converted to the OEM codepage before being printed. For ordinary strings, the local encoded version is wrapped by `localstr` if the encoding does not round-trip cleanly. This means the output encoding works even if the character is not represented in the local encoding. Unfortunately, the templater is not localstr-clean, which means strings can get flattened down to the local encoding and the original code points are lost. In this case we can only output characters which are in the intersection of the encoding and the output encoding. Most US English Windows systems use cp1252 for the ANSI code page and cp437 for the OEM code page. These both contain many accented characters, so users with accented characters in their names will now see them correctly rendered. All of this only applies to Python 2.7. In Python 3, everything is Unicode, the `--encoding` and `--outputencoding` options do nothing, and it just works. Reviewed By: quark-zju, ikostia Differential Revision: D19951381 fbshipit-source-id: d5cb8b5bfe2bc131b2e6c3b892137a48b2139ca9
2020-02-20 15:27:06 +03:00
-R --repository REPO repository root directory or name of overlay
bundle file
--cwd DIR change working directory
-y --noninteractive do not prompt, automatically pick the first choice
for all prompts
-q --quiet suppress output
-v --verbose enable additional output
--color TYPE when to colorize (boolean, always, auto, never, or
debug)
--config CONFIG [+] set/override config option (use
'section.name=value')
--configfile FILE [+] enables the given config file
--debug enable debugging output
--debugger start debugger
--encoding ENCODE set the charset encoding (default: utf-8)
--encodingmode MODE set the charset encoding mode (default: strict)
--outputencoding ENCODE set the output encoding (default: utf-8)
--traceback always print a traceback on exception
--time time how long the command takes
--profile print command execution profile
--version output version information and exit
-h --help display help and exit
--hidden consider hidden changesets
--pager TYPE when to paginate (boolean, always, auto, or never)
(default: auto)
Subcommands:
alpha, alfa other test subcommand alpha
(use 'hg help othertest SUBCOMMAND' to show complete subcommand help)
$ hg help xt
alias for: test
hg test SUBCOMMAND
test command
First Category:
one first test subcommand
Other Subcommands:
two second test subcommand
(use 'hg help test SUBCOMMAND' to show complete subcommand help)
(some details hidden, use --verbose to show complete help)
$ hg help xt one
alias for: test one
hg test one
first test subcommand
(some details hidden, use --verbose to show complete help)
$ hg help xt1
alias for: test one
hg test one
first test subcommand
(some details hidden, use --verbose to show complete help)
$ hg othertest alpha beta --help
hg othertest alpha beta
other test subcommand alpha subcommand beta
(some details hidden, use --verbose to show complete help)