New command line switch --
Add a new command line switch "--" for passing arguments to scripts.
Any arguments after -- are not processed and passed unchanged via
the usual argv mechanism.
Custom arguments can be accessed from a bpy script in python's
sys.argv. Example:
import sys
# slice argv after '--'
i = sys.argv.index('--')
my_args = sys.argv[i+1:]
This commit is contained in:
@@ -216,6 +216,8 @@ static void print_help(void)
|
||||
printf (" -R\t\tRegister .blend extension\n");
|
||||
#endif
|
||||
printf (" -v\t\tPrint Blender version and exit\n");
|
||||
printf (" --\t\tEnds option processing. Following arguments are \n");
|
||||
printf (" \t\t passed unchanged. Access via Python's sys.argv\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -314,6 +316,12 @@ int main(int argc, char **argv)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* end argument processing after -- */
|
||||
if (!strcmp( argv[a], "--")){
|
||||
a = argc;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Handle long version request */
|
||||
if (!strcmp(argv[a], "--version")){
|
||||
print_version();
|
||||
@@ -500,6 +508,10 @@ int main(int argc, char **argv)
|
||||
|
||||
if(argv[a][0] == '-') {
|
||||
switch(argv[a][1]) {
|
||||
case '-': /* -- ends argument processing */
|
||||
a = argc;
|
||||
break;
|
||||
|
||||
case 'p': /* prefsize */
|
||||
a+= 4;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user