@@ -18,6 +18,8 @@ static cli_command cli_commands[] =
18
18
{.cli_command = & cli_history , .cli_command_name = "history" , .cli_command_description = "Prints command history." },
19
19
{.cli_command = & cli_clear , .cli_command_name = "clear" , .cli_command_description = "Clears CLI screen." },
20
20
{.cli_command = & cli_help , .cli_command_name = "help" , .cli_command_description = "Prints command descriptions." },
21
+ {.cli_command = & cli_echo , .cli_command_name = "echo" , .cli_command_description = "Echoes the input." },
22
+ {.cli_command = & cli_whoami , .cli_command_name = "whoami" , .cli_command_description = "Prints the user name." },
21
23
}; // do not add NULLs at the end
22
24
23
25
int cli_exit (char * * args )
@@ -69,6 +71,10 @@ int cli_help(char** args)
69
71
guarded_printf (" * Detailed information about clear command:\n * clear - Clears CLI screen.\n" );
70
72
else if (strcmp (args [0 ], "help" ) == 0 )
71
73
guarded_printf (" * Detailed information about help command:\n * help - Prints command descriptions.\n" );
74
+ else if (strcmp (args [0 ], "echo" ) == 0 )
75
+ guarded_printf (" * Detailed information about echo command:\n * echo - Echoes the input.\n" );
76
+ else if (strcmp (args [0 ], "whoami" ) == 0 )
77
+ guarded_printf (" * Detailed information about whoami command:\n * whoami - Prints the user name.\n" );
72
78
else
73
79
guarded_printf (" * Detailed information not included.\n" );
74
80
}
@@ -77,6 +83,27 @@ int cli_help(char** args)
77
83
return 0 ;
78
84
}
79
85
86
+ int cli_echo (char * * args )
87
+ {
88
+ if (args [0 ] == NULL )
89
+ {
90
+ log_message (LOG_WARN , BITLAB_LOG , __FILE__ , "No arguments provided for echo command" );
91
+ return 1 ;
92
+ }
93
+ for (int i = 0 ; args [i ] != NULL ; ++ i )
94
+ guarded_printf ("%s " , args [i ]);
95
+ guarded_printf ("\n" );
96
+ return 0 ;
97
+ }
98
+
99
+ int cli_whoami (char * * args )
100
+ {
101
+ if (args [0 ] != NULL )
102
+ log_message (LOG_WARN , BITLAB_LOG , __FILE__ , "Arguments provided for whoami command ignored" );
103
+ guarded_printf ("You are %s\n" , getenv ("USER" ));
104
+ return 0 ;
105
+ }
106
+
80
107
int cli_clear (char * * args )
81
108
{
82
109
if (args [0 ] != NULL )
0 commit comments