diff options
-rw-r--r-- | main.c | 15 | ||||
-rw-r--r-- | tests/cram/test_basic.t | 3 |
2 files changed, 15 insertions, 3 deletions
@@ -40,7 +40,7 @@ print_usage(const char *app) { printf( "Usage\n\n" - " # %s [-t] [-l] [-r] [-S] [-R] [-e '[prefix=]{\"var\": ...}'] [-E [prefix=]env.json] {-i <file> | -s \"ucode script...\"}\n" + " # %s [-t] [-l] [-r] [-S] [-R] [-x function [-x ...]] [-e '[prefix=]{\"var\": ...}'] [-E [prefix=]env.json] {-i <file> | -s \"ucode script...\"}\n" " -h, --help Print this help\n" " -i file Execute the given ucode script file\n" " -s \"ucode script...\" Execute the given string as ucode script\n" @@ -51,6 +51,7 @@ print_usage(const char *app) " -R Enable raw code mode\n" " -e Set global variables from given JSON object\n" " -E Set global variables from given JSON file\n" + " -x Disable given function\n" " -m Preload given module\n", basename(app)); } @@ -218,7 +219,7 @@ main(int argc, char **argv) ucv_object_add(uc_vm_scope_get(&vm), "ARGV", o); /* parse options */ - while ((opt = getopt(argc, argv, "hlrtSRe:E:i:s:m:")) != -1) + while ((opt = getopt(argc, argv, "hlrtSRe:E:i:s:m:x:")) != -1) { switch (opt) { case 'h': @@ -340,6 +341,16 @@ main(int argc, char **argv) case 't': uc_vm_trace_set(&vm, 1); break; + + case 'x': + o = ucv_object_get(uc_vm_scope_get(&vm), optarg, NULL); + + if (ucv_is_callable(o)) + ucv_object_delete(uc_vm_scope_get(&vm), optarg); + else + fprintf(stderr, "Unknown function %s specified\n", optarg); + + break; } } diff --git a/tests/cram/test_basic.t b/tests/cram/test_basic.t index 7296b5d..2c22131 100644 --- a/tests/cram/test_basic.t +++ b/tests/cram/test_basic.t @@ -12,7 +12,7 @@ check that ucode provides exepected help: $ ucode | sed 's/ucode-san/ucode/' Usage - # ucode [-t] [-l] [-r] [-S] [-R] [-e '[prefix=]{"var": ...}'] [-E [prefix=]env.json] {-i <file> | -s "ucode script..."} + # ucode [-t] [-l] [-r] [-S] [-R] [-x function [-x ...]] [-e '[prefix=]{"var": ...}'] [-E [prefix=]env.json] {-i <file> | -s "ucode script..."} -h, --help\tPrint this help (esc) -i file\tExecute the given ucode script file (esc) -s "ucode script..."\tExecute the given string as ucode script (esc) @@ -23,6 +23,7 @@ check that ucode provides exepected help: -R Enable raw code mode -e Set global variables from given JSON object -E Set global variables from given JSON file + -x Disable given function -m Preload given module check that ucode prints greetings: |