diff options
author | Stephen Swaney <sswaney@centurytel.net> | 2007-08-18 04:02:50 +0400 |
---|---|---|
committer | Stephen Swaney <sswaney@centurytel.net> | 2007-08-18 04:02:50 +0400 |
commit | 7e7c2fd31be04f06887c349242659b55a1a5eb62 (patch) | |
tree | 97ee527308c8fe6d89b48cb21fa33db677ca7cf4 /source/creator | |
parent | 7f3b967c30bb30b120ef51b1633e9477325f1993 (diff) |
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:]
Diffstat (limited to 'source/creator')
-rw-r--r-- | source/creator/creator.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c index 428b3586954..c9474f01b5f 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -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; |