use crate::helpers::{ run_clm, stdout, assert_exit };
const VISIBLE_COMMANDS : &[ &str ] = &[
".status",
".version.show",
".version.install",
".version.guard",
".version.list",
".version.history",
".processes",
".processes.kill",
".settings.show",
".settings.get",
".settings.set",
];
#[ test ]
fn tc079_help_command_exits_0()
{
let out = run_clm( &[ ".help" ] );
assert_exit( &out, 0 );
}
#[ test ]
fn tc080_help_lists_12_commands()
{
let out = run_clm( &[ ".help" ] );
assert_exit( &out, 0 );
let text = stdout( &out );
let cmd_lines = text
.lines()
.filter( | l | l.starts_with( ' ' ) && l.trim_start().starts_with( '.' ) )
.count();
assert_eq!(
cmd_lines, 12,
"help must list 12 commands (11 + help), found {cmd_lines}\nFull output:\n{text}"
);
}
#[ test ]
fn tc082_help_includes_available_commands_section()
{
let out = run_clm( &[ ".help" ] );
let text = stdout( &out );
assert!( text.contains( "Available commands:" ), "help must include Available commands section: {text}" );
}
#[ test ]
fn tc091_unknown_command_exits_1()
{
let out = run_clm( &[ ".nonexistent" ] );
assert_exit( &out, 1 );
}
#[ test ]
fn tc092_another_unknown_command_exits_1()
{
let out = run_clm( &[ ".zzz.nope" ] );
assert_exit( &out, 1 );
}
#[ test ]
fn tc093_empty_args_exits_0()
{
let out = run_clm( &[] );
assert_exit( &out, 0 );
assert!( stdout( &out ).contains( "Available commands:" ), "empty args must show help" );
}
#[ test ]
fn tc094_help_exits_0_and_shows_commands()
{
let out = run_clm( &[ ".help" ] );
assert_exit( &out, 0 );
let text = stdout( &out );
for cmd in &[ ".status", ".processes", ".settings.get" ]
{
assert!( text.contains( cmd ), ".help output must mention {cmd}" );
}
}
#[ test ]
fn tc095_all_visible_commands_in_help()
{
let out = run_clm( &[ ".help" ] );
let text = stdout( &out );
for cmd in VISIBLE_COMMANDS
{
assert!( text.contains( cmd ), "help output must contain '{cmd}'\nFull output:\n{text}" );
}
}