std::vector<const char*> args;
argv_to_vec(argc, argv, args);
if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
usage();
+ exit(0);
}
std::map<std::string,std::string> defaults = {
} else if (ceph_argparse_flag(args, i, "--localize-reads", (char*)nullptr)) {
cerr << "setting CEPH_OSD_FLAG_LOCALIZE_READS" << std::endl;
filer_flags |= CEPH_OSD_FLAG_LOCALIZE_READS;
- } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)nullptr)) {
- usage();
} else {
++i;
}
MonClient *mc = new MonClient(g_ceph_context);
int r = mc->build_initial_monmap();
- if (r == -EINVAL)
- usage();
+ if (r == -EINVAL) {
+ cerr << "failed to generate initial mon list" << std::endl;
+ exit(1);
+ }
if (r < 0)
goto out_mc_start_failed;
if (!err.empty()) {
derr << "error parsing " << opt_name << ": failed to parse rank. "
<< "It must be an int." << "\n" << dendl;
- usage();
+ exit(1);
}
return ret;
}
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
auto cct = global_init(NULL, args,
CEPH_ENTITY_TYPE_MDS, CODE_ENVIRONMENT_DAEMON,
if (ceph_argparse_double_dash(args, i)) {
break;
}
- else if (ceph_argparse_flag(args, i, "--help", "-h", (char*)NULL)) {
- // exit(1) will be called in the usage()
- usage();
- }
else if (ceph_argparse_witharg(args, i, &val, "--hot-standby", (char*)NULL)) {
int r = parse_rank("hot-standby", val);
dout(0) << "requesting standby_replay for mds." << r << dendl;
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ }
map<string,string> defaults = {
{ "keyring", "$mgr_data/keyring" }
CODE_ENVIRONMENT_DAEMON, 0,
"mgr_data");
- // Handle --help
- if ((args.size() == 1 && (std::string(args[0]) == "--help" ||
- std::string(args[0]) == "-h"))) {
- usage();
- }
-
pick_addresses(g_ceph_context, CEPH_PICK_ADDRESS_PUBLIC);
global_init_daemonize(g_ceph_context);
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
// We need to specify some default values that may be overridden by the
// user, that are specific to the monitor. The options we are overriding
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
- } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage();
} else if (ceph_argparse_flag(args, i, "--mkfs", (char*)NULL)) {
mkfs = true;
} else if (ceph_argparse_flag(args, i, "--compact", (char*)NULL)) {
}
}
if (!args.empty()) {
- derr << "too many arguments: " << args << dendl;
- usage();
+ cerr << "too many arguments: " << args << std::endl;
+ exit(1);
}
if (force_sync && !yes_really) {
- derr << "are you SURE you want to force a sync? this will erase local data and may\n"
- << "break your mon cluster. pass --yes-i-really-mean-it if you do." << dendl;
+ cerr << "are you SURE you want to force a sync? this will erase local data and may\n"
+ << "break your mon cluster. pass --yes-i-really-mean-it if you do." << std::endl;
exit(1);
}
if (g_conf->mon_data.empty()) {
- derr << "must specify '--mon-data=foo' data path" << dendl;
- usage();
+ cerr << "must specify '--mon-data=foo' data path" << std::endl;
+ exit(1);
}
if (g_conf->name.get_id().empty()) {
- derr << "must specify id (--id <id> or --name mon.<id>)" << dendl;
- usage();
+ cerr << "must specify id (--id <id> or --name mon.<id>)" << std::endl;
+ exit(1);
}
// -- mkfs --
if (err < 0) {
derr << argv[0] << ": error generating initial monmap: "
<< cpp_strerror(err) << dendl;
- usage();
prefork.exit(1);
}
if (tmpmap.contains(g_conf->name.get_id())) {
{
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
map<string,string> defaults = {
// We want to enable leveldb's log, while allowing users to override this
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
- } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage();
} else if (ceph_argparse_flag(args, i, "--mkfs", (char*)NULL)) {
mkfs = true;
} else if (ceph_argparse_flag(args, i, "--mkjournal", (char*)NULL)) {
cout.flush();
}
+bool ceph_argparse_need_usage(const std::vector<const char*>& args)
+{
+ if (args.empty()) {
+ return true;
+ }
+ for (auto a : args) {
+ if (strcmp(a, "-h") == 0 ||
+ strcmp(a, "--help") == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
void generic_server_usage()
{
generic_usage(true);
- exit(1);
}
+
void generic_client_usage()
{
generic_usage(false);
- exit(1);
}
extern CephInitParameters ceph_argparse_early_args
(std::vector<const char*>& args, uint32_t module_type,
std::string *cluster, std::string *conf_file_list);
+extern bool ceph_argparse_need_usage(const std::vector<const char*>& args);
extern void generic_server_usage();
extern void generic_client_usage();
{
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage_exit();
+ }
bool opt_version = false;
bool opt_vernum = false;
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage(argv[0]);
+ exit(0);
+ }
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY, 0);
cerr << "Unable to parse mapping string: '" << val << "'" << std::endl;
return 1;
}
- } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage(argv[0]);
- return 0;
} else if (ceph_argparse_flag(args, i, "--dump-perf-counters", (char*)NULL)) {
dump_perf_counters = true;
} else if (get_remainder(*i, "-")) {
{
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY, 0);
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
- } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage();
- ceph_abort();
} else if (ceph_argparse_witharg(args, i, &val, "-i", "--uid", (char*)NULL)) {
user_id.from_str(val);
} else if (ceph_argparse_witharg(args, i, &val, "--tenant", (char*)NULL)) {
key_type = KEY_TYPE_S3;
} else {
cerr << "bad key type: " << key_type_str << std::endl;
- usage();
- ceph_abort();
+ exit(1);
}
} else if (ceph_argparse_witharg(args, i, &val, "--job-id", (char*)NULL)) {
job_id = val;
bucket_id = val;
if (bucket_id.empty()) {
cerr << "bad bucket-id" << std::endl;
- usage();
- ceph_abort();
+ exit(1);
}
} else if (ceph_argparse_witharg(args, i, &val, "--format", (char*)NULL)) {
format = val;
if (args.empty()) {
usage();
- ceph_abort();
+ exit(1);
}
else {
const char *prev_cmd = NULL;
opt_cmd = get_cmd(*i, prev_cmd, prev_prev_cmd, &need_more);
if (opt_cmd < 0) {
cerr << "unrecognized arg " << *i << std::endl;
- usage();
- ceph_abort();
+ exit(1);
}
if (!need_more) {
++i;
}
if (opt_cmd == OPT_NO_CMD) {
- usage();
- ceph_abort();
+ cerr << "no command" << std::endl;
+ exit(1);
}
/* some commands may have an optional extra param */
formatter = new JSONFormatter(pretty_format);
else {
cerr << "unrecognized format: " << format << std::endl;
- usage();
- ceph_abort();
+ exit(1);
}
realm_name = g_conf->rgw_realm;
if (opt_cmd == OPT_LOG_SHOW || opt_cmd == OPT_LOG_RM) {
if (object.empty() && (date.empty() || bucket_name.empty() || bucket_id.empty())) {
cerr << "specify an object or a date, bucket and bucket-id" << std::endl;
- usage();
- ceph_abort();
+ exit(1);
}
string oid;
if (opt_cmd == OPT_POOL_ADD) {
if (pool_name.empty()) {
cerr << "need to specify pool to add!" << std::endl;
- usage();
- ceph_abort();
+ exit(1);
}
int ret = store->add_bucket_placement(pool);
if (opt_cmd == OPT_POOL_RM) {
if (pool_name.empty()) {
cerr << "need to specify pool to remove!" << std::endl;
- usage();
- ceph_abort();
+ exit(1);
}
int ret = store->remove_bucket_placement(pool);
static int usage()
{
- cerr << "usage: radosgw [options...]" << std::endl;
- cerr << "options:\n";
- cerr << " --rgw-region=<region> region in which radosgw runs\n";
- cerr << " --rgw-zone=<zone> zone in which radosgw runs\n";
- cerr << " --rgw-socket-path=<path> specify a unix domain socket path\n";
- cerr << " -m monaddress[:port] connect to specified monitor\n";
- cerr << " --keyring=<path> path to radosgw keyring\n";
- cerr << " --logfile=<logfile> file to log debug output\n";
- cerr << " --debug-rgw=<log-level>/<memory-level> set radosgw debug level\n";
+ cout << "usage: radosgw [options...]" << std::endl;
+ cout << "options:\n";
+ cout << " --rgw-region=<region> region in which radosgw runs\n";
+ cout << " --rgw-zone=<zone> zone in which radosgw runs\n";
+ cout << " --rgw-socket-path=<path> specify a unix domain socket path\n";
+ cout << " -m monaddress[:port] connect to specified monitor\n";
+ cout << " --keyring=<path> path to radosgw keyring\n";
+ cout << " --logfile=<logfile> file to log debug output\n";
+ cout << " --debug-rgw=<log-level>/<memory-level> set radosgw debug level\n";
generic_server_usage();
return 0;
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
// First, let's determine which frontends are configured.
int flags = CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS;
CODE_ENVIRONMENT_DAEMON,
flags, "rgw_data", false);
- for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ++i) {
- if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage();
- return 0;
- }
- }
-
// maintain existing region root pool for new multisite objects
if (!g_conf->rgw_region_root_pool.empty()) {
const char *root_pool = g_conf->rgw_region_root_pool.c_str();
{
vector<const char *> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_DAEMON,
for (std::vector<const char *>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
- } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage();
- return 0;
}
}
std::string val;
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY, 0);
if ((! do_encode) ||
(type == RGWToken::TOKEN_NONE)) {
- usage();
return -EINVAL;
}
static void usage()
{
- cerr << "usage: TestSignalHandlers [test]" << std::endl;
- cerr << "--simple_segv: run simple_segv test" << std::endl;
- cerr << "--infinite_recursion: run infinite_recursion test" << std::endl;
- generic_client_usage(); // Will exit()
+ cout << "usage: TestSignalHandlers [test]" << std::endl;
+ cout << "--simple_segv: run simple_segv test" << std::endl;
+ cout << "--infinite_recursion: run infinite_recursion test" << std::endl;
+ generic_client_usage();
}
typedef void (*test_fn_t)(void);
{
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY,
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
- } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage();
} else if (ceph_argparse_flag(args, i, "--infinite_recursion", (char*)NULL)) {
fn = infinite_recursion_test;
} else if (ceph_argparse_flag(args, i, "-s", "--simple_segv", (char*)NULL)) {
fn = simple_segv_test;
} else {
- cerr << "Garbage at end of command line." << std::endl;
- usage();
+ cerr << "unrecognized argument: " << *i << std::endl;
+ exit(1);
}
}
if (!fn) {
std::cerr << "Please select a test to run. Type -h for help." << std::endl;
- usage();
+ exit(1);
}
fn();
return 0;
# TODO synchronize with man page
$ ceph-authtool --help
- no command specified
usage: ceph-authtool keyringfile [OPTIONS]...
where the options are:
-l, --list will list all keys and capabilities present in
$ ceph-authtool
- ceph-authtool: must specify filename
- usage: ceph-authtool keyringfile [OPTIONS]...
- where the options are:
- -l, --list will list all keys and capabilities present in
- the keyring
- -p, --print-key will print an encoded key for the specified
- entityname. This is suitable for the
- 'mount -o secret=..' argument
- -C, --create-keyring will create a new keyring, overwriting any
- existing keyringfile
- -g, --gen-key will generate a new secret key for the
- specified entityname
- --gen-print-key will generate a new secret key without set it
- to the keyringfile, prints the secret to stdout
- --import-keyring FILE will import the content of a given keyring
- into the keyringfile
- -n NAME, --name NAME specify entityname to operate on
- -u AUID, --set-uid AUID sets the auid (authenticated user id) for the
- specified entityname
- -a BASE64, --add-key BASE64 will add an encoded key to the keyring
- --cap SUBSYSTEM CAPABILITY will set the capability for given subsystem
- --caps CAPSFILE will set all of capabilities associated with a
- given key, for all subsystems
+ ceph-authtool: -h or --help for usage
[1]
# demonstrate that manpage examples fail without config
$ ceph-authtool
- ceph-authtool: must specify filename
- usage: ceph-authtool keyringfile [OPTIONS]...
- where the options are:
- -l, --list will list all keys and capabilities present in
- the keyring
- -p, --print-key will print an encoded key for the specified
- entityname. This is suitable for the
- 'mount -o secret=..' argument
- -C, --create-keyring will create a new keyring, overwriting any
- existing keyringfile
- -g, --gen-key will generate a new secret key for the
- specified entityname
- --gen-print-key will generate a new secret key without set it
- to the keyringfile, prints the secret to stdout
- --import-keyring FILE will import the content of a given keyring
- into the keyringfile
- -n NAME, --name NAME specify entityname to operate on
- -u AUID, --set-uid AUID sets the auid (authenticated user id) for the
- specified entityname
- -a BASE64, --add-key BASE64 will add an encoded key to the keyring
- --cap SUBSYSTEM CAPABILITY will set the capability for given subsystem
- --caps CAPSFILE will set all of capabilities associated with a
- given key, for all subsystems
+ ceph-authtool: -h or --help for usage
[1]
compact-range <prefix> <start> <end>
repair
- [1]
$ monmaptool
- monmaptool: must specify monmap filename
- usage: [--print] [--create [--clobber][--fsid uuid]]
- [--generate] [--set-initial-members]
- [--add name 1.2.3.4:567] [--rm name]
- [--feature-list [plain|parseable]]
- [--feature-set <value> [--optional|--persistent]]
- [--feature-unset <value> [--optional|--persistent]] <mapfilename>
+ monmaptool: -h or --help for usage
[1]
$ osdmaptool
- osdmaptool: must specify osdmap filename
- usage: [--print] [--createsimple <numosd> [--clobber] [--pg_bits <bitsperosd>]] <mapfilename>
- --export-crush <file> write osdmap's crush map to <file>
- --import-crush <file> replace osdmap's crush map with <file>
- --test-map-pgs [--pool <poolid>] [--pg_num <pg_num>] map all pgs
- --test-map-pgs-dump [--pool <poolid>] map all pgs
- --test-map-pgs-dump-all [--pool <poolid>] map all pgs to osds
- --health dump health checks
- --mark-up-in mark osds up and in (but do not persist)
- --mark-out <osdid> mark an osd as out (but do not persist)
- --with-default-pool include default pool when creating map
- --clear-temp clear pg_temp and primary_temp
- --test-random do random placements
- --test-map-pg <pgid> map a pgid to osds
- --test-map-object <objectname> [--pool <poolid>] map an object to osds
- --upmap-cleanup <file> clean up pg_upmap[_items] entries, writing
- commands to <file> [default: - for stdout]
- --upmap <file> calculate pg upmap entries to balance pg layout
- writing commands to <file> [default: - for stdout]
- --upmap-max <max-count> set max upmap entries to calculate [default: 100]
- --upmap-deviation <max-deviation>
- max deviation from target [default: .01]
- --upmap-pool <poolname> restrict upmap balancing to 1 or more pools
- --upmap-save write modified OSDMap with upmap changes
+ osdmaptool: -h or --help for usage
[1]
--setgroup GROUP set gid to group or gid
--version show version and quit
- [1]
static void usage()
{
- derr << "usage: ceph_objectstore_bench [flags]\n"
+ cout << "usage: ceph_objectstore_bench [flags]\n"
" --size\n"
" total size in bytes\n"
" --block-size\n"
" --threads\n"
" number of threads to carry out this workload\n"
" --multi-object\n"
- " have each thread write to a separate object\n" << dendl;
+ " have each thread write to a separate object\n" << std::endl;
generic_server_usage();
}
std::string err;
if (!cfg.size.parse(val, &err)) {
derr << "error parsing size: " << err << dendl;
- usage();
+ exit(1);
}
} else if (ceph_argparse_witharg(args, i, &val, "--block-size", (char*)nullptr)) {
std::string err;
if (!cfg.block_size.parse(val, &err)) {
derr << "error parsing block-size: " << err << dendl;
- usage();
+ exit(1);
}
} else if (ceph_argparse_witharg(args, i, &val, "--repeats", (char*)nullptr)) {
cfg.repeats = atoi(val.c_str());
cfg.multi_object = true;
} else {
derr << "Error: can't understand argument: " << *i << "\n" << dendl;
- usage();
+ exit(1);
}
}
{
std::vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY,
CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
- for (auto i = args.begin(); i != args.end(); ++i) {
- if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage();
- return EXIT_SUCCESS;
- }
- }
-
if (args.size() < 2) {
usage();
return EXIT_FAILURE;
int main(int argc, char **argv) {
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage(argv[0]);
+ exit(0);
+ }
auto cct = global_init(0, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY,
// Argument handling
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY,
// Expect exactly one positional argument (inode number)
if (args.size() != 1) {
- usage();
+ cerr << "missing position argument (inode number)" << std::endl;
+ exit(1);
}
char const *inode_str = args[0];
inodeno_t inode = strtoll(inode_str, NULL, 0);
map<string,bufferlist> caps;
std::string fn;
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
+
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY,
CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
void usage(const char *pname)
{
- std::cerr << "Usage: " << pname << " <leveldb|rocksdb|bluestore-kv> <store path> command [args...]\n"
+ std::cout << "Usage: " << pname << " <leveldb|rocksdb|bluestore-kv> <store path> command [args...]\n"
<< "\n"
<< "Commands:\n"
<< " list [prefix]\n"
{
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage(argv[0]);
+ exit(0);
+ }
auto cct = global_init(
NULL, args,
if (vm.count("debug")) debug = true;
+ if (vm.count("help")) {
+ std::cerr << desc << std::endl;
+ return 1;
+ }
+
auto cct = global_init(
NULL, ceph_options, CEPH_ENTITY_TYPE_OSD,
CODE_ENVIRONMENT_UTILITY_NODOUT, 0);
}
g_conf->apply_changes(NULL);
- if (vm.count("help")) {
- std::cerr << desc << std::endl;
- return 1;
- }
-
if (vm.count("omap-path") == 0) {
std::cerr << "Required argument --omap-path" << std::endl;
return 1;
// Parse args
// ==========
if (args.size() < 1) {
- usage();
+ cerr << "missing position argument" << std::endl;
return -EINVAL;
}
command == "cleanup") {
if (data_pool_name.empty()) {
std::cerr << "Data pool not specified" << std::endl;
- usage();
return -EINVAL;
}
// Common arg parsing
// ==================
if (argv.empty()) {
- usage();
+ cerr << "missing positional argument" << std::endl;
return -EINVAL;
}
} else if (type == std::string("mdlog") && mode == std::string("event")) {
r = main_event(argv);
} else {
- derr << "Bad command '" << mode << "'" << dendl;
- usage();
+ cerr << "Bad command '" << mode << "'" << std::endl;
return -EINVAL;
}
force = true;
} else {
std::cerr << "Unknown argument " << argv[1] << std::endl;
- usage();
return -EINVAL;
}
} else if (argv.size() > 2) {
std::cerr << "Too many arguments!" << std::endl;
- usage();
return -EINVAL;
}
return journal_reset(force);
std::string command = *(arg++);
if (command != "get" && command != "splice" && command != "recover_dentries") {
derr << "Unknown argument '" << command << "'" << dendl;
- usage();
return -EINVAL;
}
if (arg == argv.end()) {
derr << "Incomplete command line" << dendl;
- usage();
return -EINVAL;
}
// Parse output options
// ====================
if (arg == argv.end()) {
- derr << "Missing output command" << dendl;
- usage();
+ cerr << "Missing output command" << std::endl;
+ return -EINVAL;
}
std::string output_style = *(arg++);
if (output_style != "binary" && output_style != "json" &&
output_style != "summary" && output_style != "list") {
- derr << "Unknown argument: '" << output_style << "'" << dendl;
- usage();
- return -EINVAL;
+ cerr << "Unknown argument: '" << output_style << "'" << std::endl;
+ return -EINVAL;
}
std::string output_path = "dump";
assert(r == 0);
other_pool = true;
} else {
- derr << "Unknown argument: '" << *arg << "'" << dendl;
- usage();
+ cerr << "Unknown argument: '" << *arg << "'" << std::endl;
return -EINVAL;
}
}
} else {
- derr << "Unknown argument '" << command << "'" << dendl;
- usage();
+ cerr << "Unknown argument '" << command << "'" << std::endl;
return -EINVAL;
}
// Require at least 3 args <rank> <mode> <arg> [args...]
if (argv.size() < 3) {
- usage();
+ cerr << "missing required 3 arguments" << std::endl;
return -EINVAL;
}
jf.dump_int("result", r);
jf.close_section();
} else {
- derr << "Invalid table '" << table << "'" << dendl;
- usage();
+ cerr << "Invalid table '" << table << "'" << std::endl;
return -EINVAL;
}
} else if (mode == "show") {
}
jf.close_section();
} else {
- derr << "Invalid table '" << table << "'" << dendl;
- usage();
+ cerr << "Invalid table '" << table << "'" << std::endl;
return -EINVAL;
}
} else if (mode == "take_inos") {
return InoTableHandler(rank).take_inos(&io, ino, f);
}, &jf);
} else {
- derr << "Invalid mode '" << mode << "'" << dendl;
- usage();
+ cerr << "Invalid mode '" << mode << "'" << std::endl;
return -EINVAL;
}
vector<const char*> args;
argv_to_vec(argc, argv, args);
- auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
- CODE_ENVIRONMENT_UTILITY, 0);
- common_init_finish(g_ceph_context);
-
DataScan data_scan;
-
- // Handle --help before calling init() so we don't depend on network.
- if (args.empty() || (args.size() == 1 && (std::string(args[0]) == "--help" || std::string(args[0]) == "-h"))) {
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
data_scan.usage();
- return 0;
+ exit(0);
}
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_UTILITY, 0);
+ common_init_finish(g_ceph_context);
+
// Connect to mon cluster, download MDS map etc
int rc = data_scan.init();
if (rc != 0) {
{
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ JournalTool jt;
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ jt.usage();
+ exit(0);
+ }
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
- JournalTool jt;
-
- // Handle --help before calling init() so we don't depend on network.
- if (args.empty() || (args.size() == 1 && (std::string(args[0]) == "--help" || std::string(args[0]) == "-h"))) {
- jt.usage();
- return 0;
- }
// Connect to mon cluster, download MDS map etc
int rc = jt.init();
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ TableTool tt;
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ tt.usage();
+ exit(0);
+ }
+
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
- TableTool tt;
-
- // Handle --help before calling init() so we don't depend on network.
- if (args.empty() || (args.size() == 1 && (std::string(args[0]) == "--help" || std::string(args[0]) == "-h"))) {
- tt.usage();
- return 0;
- }
// Connect to mon cluster, download MDS map etc
int rc = tt.init();
{
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
const char *me = argv[0];
std::string infn, srcfn, outfn, add_name, add_type, remove_name, reweight_name;
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
- } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage();
- return EXIT_SUCCESS;
} else if (ceph_argparse_witharg(args, i, &val, "-d", "--decompile", (char*)NULL)) {
infn = val;
decompile = true;
{
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
const char *me = argv[0];
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
- } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage();
} else if (ceph_argparse_flag(args, i, "-p", "--print", (char*)NULL)) {
print = true;
} else if (ceph_argparse_flag(args, i, "--create", (char*)NULL)) {
{
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY,
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
- } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage();
} else if (ceph_argparse_flag(args, i, "-p", "--print", (char*)NULL)) {
print = true;
} else if (ceph_argparse_witharg(args, i, &val, err, "--dump", (char*)NULL)) {
{
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage(cout);
+ exit(0);
+ }
std::map < std::string, std::string > opts;
std::string val;
for (i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
- } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage(cout);
- exit(0);
} else if (ceph_argparse_flag(args, i, "--force-full", (char*)NULL)) {
opts["force-full"] = "true";
} else if (ceph_argparse_flag(args, i, "-d", "--delete-after", (char*)NULL)) {
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
std::string conf_file_list;
std::string cluster;
{
std::vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
auto cct = global_init(nullptr, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_DAEMON,
CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
- for (auto i = args.begin(); i != args.end(); ++i) {
- if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
- usage();
- return EXIT_SUCCESS;
- }
- }
-
if (g_conf->daemonize) {
global_init_daemonize(g_ceph_context);
}
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage();
+ exit(0);
+ }
auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_DAEMON,