Skip to content

Commit 078f511

Browse files
committed
revisit arguments
1 parent b2fc49d commit 078f511

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

Readme.org

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ In the same way the data fields will be cut off and a message displayed for the
304304
+--------------+
305305
#+end_src
306306

307-
Usually the chunk size is calculated from the config file, but it can be set manually with the argument ~-b / --chunksize~. (In bytes) In the case that the sum of the length of the fields in config is bigger than the size from the argument, the message "values size is bigger than what is left of that data chunk" will be displayed for the fields that have no data. If the chunk size from the argument is bigger, the remaining bytes from that chunk will not be evaluated.
307+
Usually the chunk size is calculated from the config file, but it can be set manually with the argument ~--chunksize~. (In bytes) In the case that the sum of the length of the fields in config is bigger than the size from the argument, the message "values size is bigger than what is left of that data chunk" will be displayed for the fields that have no data. If the chunk size from the argument is bigger, the remaining bytes from that chunk will not be evaluated.
308308

309309
* Record to ~--outfile~
310310
Please note that writing to a file is different that piping stdout of mview into a file like this:

src/args.rs

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ impl Args {
3535
Arg::with_name("outfile")
3636
.short('w')
3737
.long("outfile")
38+
.visible_short_alias('o')
3839
.takes_value(true)
3940
.help("Write output to a file instead of stdout"),
4041
)
@@ -53,24 +54,28 @@ impl Args {
5354
.help("Read from a PCAP formatted file or data stream"),
5455
)
5556
.arg(
56-
Arg::with_name("chunksize")
57-
.short('b')
57+
Arg::with_name("chunksize (bytes)")
58+
.short('s')
5859
.long("chunksize")
5960
.takes_value(true)
6061
.value_parser(clap::value_parser!(usize))
61-
.help("flush stdout and restart matching after n bytes"),
62+
.help("Restart matching after n bytes")
63+
.long_help("Restart matching after n bytes. If this argument is not given the size of a chunk is determined from the config.
64+
If chunksize is longer than a message, the chunk is filled with message data from the start until mview runs out of message data. Fields of the chunk that are left will not get a value.
65+
If chunksize is shorter than a message, the whole chunk will be filled with the message data, mview will print out that chunk and then start filling the next chunk with the remaining data from the message.
66+
For a graphical explaination of how mview handles message and chunk lengths see Readme.
67+
"),
6268
)
6369
.arg(
6470
Arg::with_name("offset (bytes)")
65-
.short('o')
6671
.long("offset")
72+
.visible_alias("byteoffset")
6773
.takes_value(true)
6874
.value_parser(clap::value_parser!(usize))
6975
.help("offset in bytes at the start of a chunk before parsing starts"),
7076
)
7177
.arg(
7278
Arg::with_name("offset (bits)")
73-
.short('s')
7479
.long("bitoffset")
7580
.takes_value(true)
7681
.value_parser(clap::value_parser!(usize))
@@ -80,6 +85,7 @@ impl Args {
8085
Arg::with_name("rawhex")
8186
.short('r')
8287
.long("rawhex")
88+
.visible_alias("raw")
8389
.takes_value(false)
8490
.help("Print raw hexdump of the chunk at top of output"),
8591
)
@@ -96,7 +102,7 @@ impl Args {
96102
.help("Print raw ascii of the chunk at top of output"),
97103
)
98104
.arg(
99-
Arg::with_name("pause")
105+
Arg::with_name("pause (ms)")
100106
.long("pause")
101107
.short('p')
102108
.takes_value(true)
@@ -105,7 +111,8 @@ impl Args {
105111
)
106112
.arg(
107113
Arg::with_name("little endian")
108-
.long("le")
114+
.long("little-endian")
115+
.visible_aliases(&["le", "littleendian"])
109116
.takes_value(false)
110117
.help("Interpret integers as little endian (default is big endian)."),
111118
)
@@ -117,12 +124,11 @@ impl Args {
117124
.help("Display timestamp of each chunk."),
118125
)
119126
.arg(
120-
Arg::with_name("read head")
121-
.short('h')
127+
Arg::with_name("head (bytes)")
122128
.long("head")
123129
.takes_value(true)
124130
.value_parser(clap::value_parser!(usize))
125-
.help("Read only the first x bytes where is the number given and then exit."),
131+
.help("Read only the first x bytes where x is the number given, print that as a message and then exit."),
126132
)
127133
.arg(
128134
Arg::with_name("print statistics")
@@ -140,7 +146,9 @@ impl Args {
140146
Arg::with_name("no cursor jumping")
141147
.long("--nojump")
142148
.takes_value(false)
143-
.help("Print to stdout like printing to a file with option --outfile"),
149+
.help("Print to stdout like printing to a file with option --outfile")
150+
.long_help("Print to stdout like printing to a file with option --outfile. Do not jump back the amount of lines printed before printing the next chunk when printing to stdout."),
151+
)
144152
.arg(
145153
Arg::with_name("clear")
146154
.long("--clear")
@@ -152,36 +160,38 @@ impl Args {
152160
Arg::with_name("filter newlines")
153161
.long("--filter-newlines")
154162
.takes_value(false)
155-
.help("Filter newline characters from string fields"),
163+
.help("Filter newline characters from string fields")
164+
.long_help("Filter newline characters from string fields. Normally mview tries to not alter the data of a message and prints it 'as is'.
165+
However, this can result it a mess when strings in the message contain control characters like \\n. To avoid making a mess this argument lets mview filter the strings from newline characters"),
156166
)
157167
.get_matches();
158168
let infile = matches.value_of("infile").unwrap_or_default().to_string();
159169
let outfile = matches.value_of("outfile").unwrap_or_default().to_string();
160170
let config = matches.value_of("config").unwrap_or_default().to_string();
161171
let pcap = matches.is_present("pcap");
162172
let chunksize = matches
163-
.try_get_one::<usize>("chunksize")
173+
.try_get_one::<usize>("chunksize (bytes)")
164174
.unwrap_or_default()
165175
.unwrap_or(&0);
166176
let offset = matches
167-
.try_get_one::<usize>("offset")
177+
.try_get_one::<usize>("offset (bytes)")
168178
.unwrap_or_default()
169179
.unwrap_or(&0);
170180
let bitoffset = matches
171-
.try_get_one::<usize>("bitoffset")
181+
.try_get_one::<usize>("offset (bits)")
172182
.unwrap_or_default()
173183
.unwrap_or(&0);
174184
let rawhex = matches.is_present("rawhex");
175185
let rawbin = matches.is_present("rawbin");
176186
let rawascii = matches.is_present("rawascii");
177187
let pause = matches
178-
.try_get_one::<u64>("pause")
188+
.try_get_one::<u64>("pause (ms)")
179189
.unwrap_or_default()
180190
.unwrap_or(&0);
181191
let little_endian = matches.is_present("little endian");
182192
let timestamp = matches.is_present("timestamp");
183193
let read_head = matches
184-
.try_get_one::<usize>("read head")
194+
.try_get_one::<usize>("head (bytes)")
185195
.unwrap_or_default()
186196
.unwrap_or(&0);
187197
let print_statistics = matches.is_present("print statistics");

0 commit comments

Comments
 (0)