| 630 | } |
| 631 | |
| 632 | int main(int argc, char *argv[]) |
| 633 | { |
| 634 | setup_locale(); |
| 635 | |
| 636 | int fd; |
| 637 | size_t off; |
| 638 | const char *method; |
| 639 | char *cmd, *resp, *idstr; |
| 640 | struct sockaddr_un addr; |
| 641 | jsmntok_t *toks; |
| 642 | const jsmntok_t *result, *error, *id; |
| 643 | const tal_t *ctx = tal(NULL, char); |
| 644 | char *config_filename, *base_dir, *net_dir, *rpc_filename; |
| 645 | jsmn_parser parser; |
| 646 | int parserr; |
| 647 | enum format format = DEFAULT_FORMAT; |
| 648 | enum input input = DEFAULT_INPUT; |
| 649 | enum log_level notification_level = LOG_INFORM; |
| 650 | bool last_was_progress = false; |
| 651 | char *command = NULL, *filter = NULL; |
| 652 | struct commando *commando = NULL; |
| 653 | |
| 654 | err_set_progname(argv[0]); |
| 655 | jsmn_init(&parser); |
| 656 | |
| 657 | tal_set_backend(NULL, NULL, NULL, tal_error); |
| 658 | |
| 659 | setup_option_allocators(); |
| 660 | |
| 661 | opt_exitcode = ERROR_USAGE; |
| 662 | minimal_config_opts(ctx, argc, argv, &config_filename, &base_dir, |
| 663 | &net_dir, &rpc_filename); |
| 664 | |
| 665 | opt_register_noarg("--help|-h", opt_usage_and_exit, |
| 666 | "<command> [<params>...]", "Show this message. Use the command help (without hyphens -- \"lightning-cli help\") to get a list of all RPC commands"); |
| 667 | opt_register_noarg("-H|--human-readable", opt_set_human, &format, |
| 668 | "Human-readable output"); |
| 669 | opt_register_noarg("-F|--flat", opt_set_flat, &format, |
| 670 | "Flatten output ('x.y.x=' format)"); |
| 671 | opt_register_noarg("-J|--json", opt_set_json, &format, |
| 672 | "JSON output (default unless 'help')"); |
| 673 | opt_register_noarg("-R|--raw", opt_set_raw, &format, |
| 674 | "Raw, unformatted JSON output"); |
| 675 | opt_register_noarg("-k|--keywords", opt_set_keywords, &input, |
| 676 | "Use format key=value for <params>"); |
| 677 | opt_register_noarg("-o|--order", opt_set_ordered, &input, |
| 678 | "Use params in order for <params>"); |
| 679 | opt_register_arg("-N|--notifications", opt_set_level, |
| 680 | opt_show_level, ¬ification_level, |
| 681 | "Set notification level, or none"); |
| 682 | opt_register_arg("-l|--filter", opt_set_charp, |
| 683 | opt_show_charp, &filter, |
| 684 | "Set JSON reply filter"); |
| 685 | opt_register_arg("-c|--commando", opt_set_commando, |
| 686 | NULL, &commando, |
| 687 | "Send this as a commando command to nodeid:rune"); |
| 688 | |
| 689 | opt_early_parse(argc, argv, opt_log_stderr_exit_usage); |
nothing calls this directly
no test coverage detected