Skip to content

Commit e43841f

Browse files
authored
Fixed help information (#22)
1 parent b811507 commit e43841f

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ int main(int argc, char** argv)
2828
branch_subcommand(lg2_obj, app);
2929
checkout_subcommand(lg2_obj, app);
3030

31-
app.parse(argc, argv);
31+
CLI11_PARSE(app, argc, argv);
3232

3333
if (version->count())
3434
{
3535
std::cout << "git2cpp version " << GIT2CPP_VERSION_STRING << " (libgit2 " << LIBGIT2_VERSION << ")" << std::endl;
3636
}
37+
38+
if (app.get_subcommands().size() == 0)
39+
{
40+
std::cout << app.help() << std::endl;
41+
}
3742
}
3843
catch (const CLI::Error& e)
3944
{

test/test_git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ def test_version(git2cpp_path, arg):
1414
def test_error_on_unknown_option(git2cpp_path):
1515
cmd = [git2cpp_path, '--unknown']
1616
p = subprocess.run(cmd, capture_output=True)
17-
assert p.returncode == 1
17+
assert p.returncode == 109
1818
assert p.stdout == b''
1919
assert p.stderr.startswith(b"The following argument was not expected: --unknown")

test/test_init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ def test_init_in_cwd(git2cpp_path, tmp_path, run_in_tmp_path):
4343
def test_error_on_unknown_option(git2cpp_path):
4444
cmd = [git2cpp_path, 'init', '--unknown']
4545
p = subprocess.run(cmd, capture_output=True)
46-
assert p.returncode == 1
46+
assert p.returncode == 109
4747
assert p.stdout == b''
4848
assert p.stderr.startswith(b"The following argument was not expected: --unknown")
4949

5050

5151
def test_error_on_repeated_directory(git2cpp_path):
5252
cmd = [git2cpp_path, 'init', 'abc', 'def']
5353
p = subprocess.run(cmd, capture_output=True)
54-
assert p.returncode == 1
54+
assert p.returncode == 109
5555
assert p.stdout == b''
5656
assert p.stderr.startswith(b"The following argument was not expected: def")

0 commit comments

Comments
 (0)