mirror of
https://github.com/roswell/roswell.git
synced 2026-09-10 07:16:17 -04:00
prepare for improving 'ros help install'
This commit is contained in:
parent
feef4d41d1
commit
f5d47712eb
|
|
@ -22,6 +22,9 @@ int cmd_help(int argc, const char **argv)
|
|||
}
|
||||
if(help) {
|
||||
struct command_help* h=firstp(help);
|
||||
if(h->call) {
|
||||
return h->call(argc-1,(char**)&(argv[1]),NULL);
|
||||
}
|
||||
if(h->usage)
|
||||
fprintf(stderr,h->usage,argv_orig[0]);
|
||||
|
||||
|
|
@ -56,7 +59,6 @@ int cmd_help(int argc, const char **argv)
|
|||
fmt=s_cat(q(" %-"),qsprintf(5,"%d",cmdmax+2),q("s%s\n"),NULL);
|
||||
else
|
||||
fmt=s_cat(q(" %-"),qsprintf(5,"%d",optmax+2),q("s --%-"),qsprintf(5,"%d",cmdmax+2),q("s%s"),NULL);
|
||||
|
||||
for(p=pinit;p;p=Next(p)) {
|
||||
struct sub_command* fp=firstp(p);
|
||||
if(fp && fp->name && fp->show_opt) {
|
||||
|
|
|
|||
|
|
@ -199,12 +199,13 @@ int cmd_install(int argc,char **argv,struct sub_command* cmd)
|
|||
fprintf(stderr,"%s:",argv[i]);
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
tmp=(char**)alloc(sizeof(char*)*(argc+8));
|
||||
tmp=(char**)alloc(sizeof(char*)*(argc+9));
|
||||
i=0;
|
||||
tmp[i++]=q("--no-rc");
|
||||
tmp[i++]=q("lisp=sbcl-bin");
|
||||
tmp[i++]=q("--");
|
||||
tmp[i++]=install_ros;
|
||||
tmp[i++]=q("install");
|
||||
tmp[i++]=q(argv[1]);
|
||||
tmp[i++]=sexp_opts(local_opt);
|
||||
tmp[i++]=sexp_opts(global_opt);
|
||||
|
|
@ -242,13 +243,25 @@ int cmd_install(int argc,char **argv,struct sub_command* cmd)
|
|||
s(param.expand_path);
|
||||
}
|
||||
}else {
|
||||
printf("what would you like to install?\n");
|
||||
char* tmp[]={"help","install"};
|
||||
proccmd(2,tmp,top_options,top_commands);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int install_help(int argc,char **argv,struct sub_command* cmd)
|
||||
{
|
||||
int i;
|
||||
fprintf(stderr,"argc %d;\n",argc);
|
||||
for(i=0;i<argc;++i) {
|
||||
printf("%d %s\n",i,argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void register_cmd_install(void)
|
||||
{
|
||||
top_commands=add_command(top_commands,"install" ,NULL,cmd_install,1,1,"Install archive and build it for "PACKAGE" environment",NULL);
|
||||
top_helps=add_help(top_helps,"install",q(""),(LVal)NULL,(LVal)NULL,NULL,NULL,install_help);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,10 +168,10 @@ void register_cmd_run(void)
|
|||
top_commands=add_command(top_commands,"*" ,NULL,cmd_script,OPT_SHOW_NONE,1,"Run lisp environment then quit (default)",NULL);
|
||||
|
||||
_help=cat("Usage: ",argv_orig[0]," [OPTIONS] "ROS_RUN_REPL" [OPTIONS] [-- implementation-native-options...]\n\n",NULL);
|
||||
top_helps=add_help(top_helps,ROS_RUN_REPL,_help,run_commands,run_options,NULL,NULL);
|
||||
top_helps=add_help(top_helps,ROS_RUN_REPL,_help,run_commands,run_options,NULL,NULL,NULL);
|
||||
s(_help);
|
||||
_help=cat("Usage: ",argv_orig[0]," [OPTIONS] [--] script-file arguments...\n\n",
|
||||
NULL);
|
||||
top_helps=add_help(top_helps,"--",_help,run_commands,run_options,NULL,NULL);
|
||||
top_helps=add_help(top_helps,"--",_help,run_commands,run_options,NULL,NULL,NULL);
|
||||
s(_help);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@
|
|||
(save-opt (format nil "~A.version" (getf argv :target)) (get-opt "as"))
|
||||
(cons t argv))
|
||||
|
||||
(defun main (impl/version &rest argv)
|
||||
(format t "launched install ~A~%" impl/version)
|
||||
(defun main (subcmd impl/version &rest argv)
|
||||
(format t "launched ~A ~A~%" subcmd impl/version)
|
||||
(let* (imp
|
||||
version
|
||||
(seq impl/version)
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ int main (int argc,char **argv) {
|
|||
top_commands=nreverse(top_commands);
|
||||
_help=cat("Usage: ",argv_orig[0]," [OPTIONS] [Command arguments...] \n",
|
||||
"Usage: ",argv_orig[0]," [OPTIONS] [[--] script-path arguments...] \n\n",NULL);
|
||||
top_helps=add_help(top_helps,NULL,_help,top_commands,top_options,NULL,NULL);
|
||||
top_helps=add_help(top_helps,NULL,_help,top_commands,top_options,NULL,NULL,NULL);
|
||||
s(_help);
|
||||
|
||||
char* path=s_cat(homedir(),q("config"),NULL);
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ int set_opts_int(struct opts* opts,const char* name,int value) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
LVal add_help(LVal help,const char* name,const char* usage,LVal commands,LVal opts,const char* header,const char* footer)
|
||||
LVal add_help(LVal help,const char* name,const char* usage,LVal commands,LVal opts,const char* header,const char* footer,sub_command_fnc call)
|
||||
{
|
||||
struct command_help* p=alloc(sizeof(struct command_help));
|
||||
help=cons(p,help);
|
||||
|
|
@ -205,6 +205,7 @@ LVal add_help(LVal help,const char* name,const char* usage,LVal commands,LVal op
|
|||
p->opts=opts;
|
||||
p->header=header?q(header):NULL;
|
||||
p->footer=footer?q(footer):NULL;
|
||||
p->call=call;
|
||||
return help;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ struct command_help
|
|||
LVal opts;
|
||||
const char* header;
|
||||
const char* footer;
|
||||
sub_command_fnc call;
|
||||
};
|
||||
|
||||
extern LVal top_helps;
|
||||
|
|
@ -51,7 +52,7 @@ extern LVal subcommand_name;
|
|||
extern int verbose;
|
||||
extern int quicklisp;
|
||||
|
||||
LVal add_help(LVal help,const char* name,const char* usage,LVal commands,LVal opts,const char* header,const char* footer);
|
||||
LVal add_help(LVal help,const char* name,const char* usage,LVal commands,LVal opts,const char* header,const char* footer,sub_command_fnc call);
|
||||
LVal add_command(LVal cmd,const char* name,const char* short_name,sub_command_fnc call,int show_opt,int terminating,char* description,char* arg_example);
|
||||
struct opts* load_opts(const char* path);
|
||||
int save_opts(const char* path,struct opts* opt);
|
||||
|
|
|
|||
Loading…
Reference in a new issue