Usage cleanup pt 2
Eliminage redundant spaces and nvmecontrol at start of all the usage strings. Update the usage printing code to add them back when presenting to the user. Allow multi-line usage messages and print proper leading spaces for lines starting with a space. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D18403
This commit is contained in:
parent
7b1468f002
commit
32a1fe0af3
@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "nvmecontrol.h"
|
||||
|
||||
#define DEVLIST_USAGE \
|
||||
" nvmecontrol devlist\n"
|
||||
"devlist\n"
|
||||
|
||||
static inline uint32_t
|
||||
ns_get_sector_size(struct nvme_namespace_data *nsdata)
|
||||
|
@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "nvmecontrol.h"
|
||||
|
||||
#define FIRMWARE_USAGE \
|
||||
" nvmecontrol firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n"
|
||||
"firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n"
|
||||
|
||||
static int
|
||||
slot_has_valid_firmware(int fd, int slot)
|
||||
|
@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "nvmecontrol.h"
|
||||
|
||||
#define FORMAT_USAGE \
|
||||
" nvmecontrol format [-f fmt] [-m mset] [-p pi] [-l pil] [-E] [-C] <controller id|namespace id>\n"
|
||||
"format [-f fmt] [-m mset] [-p pi] [-l pil] [-E] [-C] <controller id|namespace id>\n"
|
||||
|
||||
static void
|
||||
format(struct nvme_function *nf, int argc, char *argv[])
|
||||
|
@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "nvmecontrol_ext.h"
|
||||
|
||||
#define IDENTIFY_USAGE \
|
||||
" nvmecontrol identify [-x [-v]] <controller id|namespace id>\n"
|
||||
"identify [-x [-v]] <controller id|namespace id>\n"
|
||||
|
||||
static void
|
||||
print_namespace(struct nvme_namespace_data *nsdata)
|
||||
|
@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$");
|
||||
SET_DECLARE(logpage, struct logpage_function);
|
||||
|
||||
#define LOGPAGE_USAGE \
|
||||
" nvmecontrol logpage <-p page_id> [-b] [-v vendor] [-x] <controller id|namespace id>\n" \
|
||||
"logpage <-p page_id> [-b] [-v vendor] [-x] <controller id|namespace id>\n" \
|
||||
|
||||
#define MAX_FW_SLOTS (7)
|
||||
|
||||
|
@ -43,22 +43,22 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
SET_DECLARE(ns, struct nvme_function);
|
||||
|
||||
#define NS_USAGE \
|
||||
" nvmecontrol ns (create|delete|attach|detach)\n"
|
||||
#define NS_USAGE \
|
||||
"ns (create|delete|attach|detach)\n"
|
||||
|
||||
/* handles NVME_OPC_NAMESPACE_MANAGEMENT and ATTACHMENT admin cmds */
|
||||
|
||||
#define NSCREATE_USAGE \
|
||||
" nvmecontrol ns create -s size [-c cap] [-f fmt] [-m mset] [-n nmic] [-p pi] [-l pil] nvmeN\n"
|
||||
"ns create -s size [-c cap] [-f fmt] [-m mset] [-n nmic] [-p pi] [-l pil] nvmeN\n"
|
||||
|
||||
#define NSDELETE_USAGE \
|
||||
" nvmecontrol ns delete -n nsid nvmeN\n"
|
||||
"ns delete -n nsid nvmeN\n"
|
||||
|
||||
#define NSATTACH_USAGE \
|
||||
" nvmecontrol ns attach -n nsid [-c ctrlrid] nvmeN \n"
|
||||
"ns attach -n nsid [-c ctrlrid] nvmeN \n"
|
||||
|
||||
#define NSDETACH_USAGE \
|
||||
" nvmecontrol ns detach -n nsid [-c ctrlrid] nvmeN\n"
|
||||
"ns detach -n nsid [-c ctrlrid] nvmeN\n"
|
||||
|
||||
void nscreate(struct nvme_function *nf, int argc, char *argv[]);
|
||||
void nsdelete(struct nvme_function *nf, int argc, char *argv[]);
|
||||
|
@ -52,7 +52,24 @@ SET_DECLARE(top, struct nvme_function);
|
||||
static void
|
||||
print_usage(const struct nvme_function *f)
|
||||
{
|
||||
fprintf(stderr, "%s", f->usage);
|
||||
const char *cp;
|
||||
char ch;
|
||||
bool need_prefix = true;
|
||||
|
||||
cp = f->usage;
|
||||
while (*cp) {
|
||||
ch = *cp++;
|
||||
if (need_prefix) {
|
||||
if (ch != ' ')
|
||||
fputs(" nvmecontrol ", stderr);
|
||||
else
|
||||
fputs(" ", stderr);
|
||||
}
|
||||
fputc(ch, stderr);
|
||||
need_prefix = (ch == '\n');
|
||||
}
|
||||
if (!need_prefix)
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -46,10 +46,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include "nvmecontrol.h"
|
||||
|
||||
#define PERFTEST_USAGE \
|
||||
" nvmecontrol perftest <-n num_threads> <-o read|write>\n" \
|
||||
" <-s size_in_bytes> <-t time_in_seconds>\n" \
|
||||
" <-i intr|wait> [-f refthread] [-p]\n" \
|
||||
" <namespace id>\n"
|
||||
"perftest <-n num_threads> <-o read|write>\n" \
|
||||
" <-s size_in_bytes> <-t time_in_seconds>\n" \
|
||||
" <-i intr|wait> [-f refthread] [-p]\n" \
|
||||
" <namespace id>\n"
|
||||
|
||||
static void
|
||||
print_perftest(struct nvme_io_test *io_test, bool perthread)
|
||||
|
@ -45,7 +45,7 @@ _Static_assert(sizeof(struct nvme_power_state) == 256 / NBBY,
|
||||
"nvme_power_state size wrong");
|
||||
|
||||
#define POWER_USAGE \
|
||||
" nvmecontrol power [-l] [-p new-state [-w workload-hint]] <controller id>\n"
|
||||
"power [-l] [-p new-state [-w workload-hint]] <controller id>\n"
|
||||
|
||||
static void
|
||||
power_list_one(int i, struct nvme_power_state *nps)
|
||||
|
@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "nvmecontrol.h"
|
||||
|
||||
#define RESET_USAGE \
|
||||
" nvmecontrol reset <controller id>\n"
|
||||
"reset <controller id>\n"
|
||||
|
||||
static void
|
||||
reset(struct nvme_function *nf, int argc, char *argv[])
|
||||
|
@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "nvmecontrol.h"
|
||||
|
||||
#define WDC_USAGE \
|
||||
" nvmecontrol wdc (cap-diag|drive-log|get-crash-dump|purge|purge-montior)\n"
|
||||
"wdc (cap-diag)\n"
|
||||
|
||||
SET_DECLARE(wdc, struct nvme_function);
|
||||
|
||||
@ -54,7 +54,7 @@ SET_DECLARE(wdc, struct nvme_function);
|
||||
|
||||
static void wdc_cap_diag(struct nvme_function *nf, int argc, char *argv[]);
|
||||
|
||||
#define WDC_CAP_DIAG_USAGE "\tnvmecontrol wdc cap-diag [-o path-template]\n"
|
||||
#define WDC_CAP_DIAG_USAGE "wdc cap-diag [-o path-template]\n"
|
||||
|
||||
NVME_COMMAND(wdc, cap-diag, wdc_cap_diag, WDC_CAP_DIAG_USAGE);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user