mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-21 10:37:34 +08:00
Linux: modified shell to not show _main suffix
The builtin commands all have _main suffix by convention so no need to show _main. Also nsh calls the commmands without the _main suffix. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
+14
-6
@@ -38,7 +38,7 @@ builtins = glob.glob("builtin_commands/COMMAND*")
|
||||
|
||||
apps = []
|
||||
for f in builtins:
|
||||
apps.append(f.split(".")[-1])
|
||||
apps.append(f.split(".")[-1].split("_main")[0])
|
||||
|
||||
print
|
||||
print """
|
||||
@@ -49,10 +49,11 @@ using namespace std;
|
||||
extern "C" {
|
||||
"""
|
||||
for app in apps:
|
||||
print "extern int "+app+"(int argc, char *argv[]);"
|
||||
print "extern int "+app+"_main(int argc, char *argv[]);"
|
||||
|
||||
print """
|
||||
static int list_builtins(int argc, char *argv[]);
|
||||
static int list_builtins_main(int argc, char *argv[]);
|
||||
static int shutdown_main(int argc, char *argv[]);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,16 +64,17 @@ static map<string,px4_main_t> app_map(void)
|
||||
map<string,px4_main_t> apps;
|
||||
"""
|
||||
for app in apps:
|
||||
print '\tapps["'+app+'"] = '+app+';'
|
||||
print '\tapps["'+app+'"] = '+app+'_main;'
|
||||
|
||||
print '\tapps["list_builtins"] = list_builtins;'
|
||||
print '\tapps["list_builtins"] = list_builtins_main;'
|
||||
print '\tapps["shutdown"] = shutdown_main;'
|
||||
print """
|
||||
return apps;
|
||||
}
|
||||
|
||||
map<string,px4_main_t> apps = app_map();
|
||||
|
||||
static int list_builtins(int argc, char *argv[])
|
||||
static int list_builtins_main(int argc, char *argv[])
|
||||
{
|
||||
cout << "Builtin Commands:" << endl;
|
||||
for (map<string,px4_main_t>::iterator it=apps.begin(); it!=apps.end(); ++it)
|
||||
@@ -80,5 +82,11 @@ static int list_builtins(int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int shutdown_main(int argc, char *argv[])
|
||||
{
|
||||
cout << "Shutting down" << endl;
|
||||
exit(0);
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user