mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-29 10:40:22 +00:00
manpage autogen
This commit is contained in:
parent
50c80ffb7c
commit
76df670715
6 changed files with 711 additions and 733 deletions
|
|
@ -466,28 +466,40 @@ cli_opts_t* parse_command_line(int argc, char** argv) {
|
|||
// the manpage-autogenerator
|
||||
} else if (streq(argv[argi], "--usage-synopsis")) {
|
||||
main_usage_synopsis(stdout, argv[0]);
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--usage-list-all-verbs")) {
|
||||
list_all_verbs(stdout);
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--usage-help-options")) {
|
||||
main_usage_help_options(stdout, argv[0]);
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--usage-functions")) {
|
||||
main_usage_functions(stdout, argv[0]);
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--usage-data-format-options")) {
|
||||
main_usage_data_format_options(stdout, argv[0]);
|
||||
} else if (streq(argv[argi], "--usage-separatorroptions")) {
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--usage-separator-options")) {
|
||||
main_usage_separator_options(stdout, argv[0]);
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--usage-csv-options")) {
|
||||
main_usage_csv_options(stdout, argv[0]);
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--usage-double-quoting")) {
|
||||
main_usage_double_quoting(stdout, argv[0]);
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--usage-numerical-formatting")) {
|
||||
main_usage_numerical_formatting(stdout, argv[0]);
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--usage-other-options")) {
|
||||
main_usage_other_options(stdout, argv[0]);
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--usage-then-chaining")) {
|
||||
main_usage_then_chaining(stdout, argv[0]);
|
||||
} else if (streq(argv[argi], "--usage-seel-also")) {
|
||||
exit(0);
|
||||
} else if (streq(argv[argi], "--usage-see-also")) {
|
||||
main_usage_see_also(stdout, argv[0]);
|
||||
exit(0);
|
||||
|
||||
} else if (streq(argv[argi], "--rs")) {
|
||||
check_arg_count(argv, argi, argc, 2);
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ TOP OF LIST
|
|||
|
||||
! join on partial value-field matches
|
||||
|
||||
MINOR: even absent manpage autogen from C, at least manually update mlr.1 to match current output
|
||||
|
||||
MINOR: brew version bump?!?
|
||||
|
||||
MINOR: faqent re R/mysql/etc inouts
|
||||
|
|
@ -47,6 +45,9 @@ MAJOR: regex
|
|||
----------------------------------------------------------------
|
||||
MAJOR: manpage
|
||||
|
||||
! portabilities in mlr.1
|
||||
! makefile/readme/etc
|
||||
|
||||
* xroff links:
|
||||
- http://www.linuxhowtos.org/System/creatingman.htm
|
||||
- https://www.gnu.org/software/groff/manual/html_node/Man-usage.html
|
||||
|
|
|
|||
|
|
@ -7,5 +7,8 @@ man1_MANS= mlr.1
|
|||
# a2x: ERROR: "xmllint" --nonet --noout --valid "/path/to/pub_http_internet/miller/doc/mlr.1.xml" returned non-zero exit status 4
|
||||
|
||||
MAINTAINERCLEANFILES= mlr.1
|
||||
# To do:
|
||||
# * ruby mkman.rb > mlr.1
|
||||
# * Needs explicit package dependency on Ruby
|
||||
mlr.1: mlr.1.txt
|
||||
cp mlr.1.premade mlr.1
|
||||
|
|
|
|||
98
doc/mkman.rb
98
doc/mkman.rb
|
|
@ -1,11 +1,19 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
# xxx note about why: mindeps
|
||||
# ================================================================
|
||||
# This is a manpage autogenerator for Miller. There are various tools out there
|
||||
# for creating xroff-formatted manpages, but I wanted something with minimal
|
||||
# external dependencies which would also automatically generate most of its
|
||||
# output from the mlr executable itself. It turns out it's easy enough to get
|
||||
# this in just a few lines of Ruby.
|
||||
#
|
||||
# Note for dev-viewing of the output:
|
||||
# ./mkman.rb | groff -man -Tascii | less
|
||||
# ================================================================
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
def main
|
||||
|
||||
# xxx emit autogen stuff: $0, hostname, date ...
|
||||
print make_top
|
||||
|
||||
print make_section('NAME', [
|
||||
|
|
@ -13,17 +21,16 @@ def main
|
|||
])
|
||||
|
||||
print make_section('SYNOPSIS', [
|
||||
"mlr [I/O options] {verb} [verb-dependent options ...] {zero or more file names}"
|
||||
`mlr --usage-synopsis`
|
||||
])
|
||||
|
||||
print make_section('DESCRIPTION', [
|
||||
"""This is something the Unix toolkit always could have done, and arguably always
|
||||
should have done. It operates on key-value-pair data while the familiar
|
||||
Unix tools operate on integer-indexed fields: if the natural data structure for
|
||||
the latter is the array, then Miller's natural data structure is the
|
||||
insertion-ordered hash map. This encompasses a variety of data formats,
|
||||
including but not limited to the familiar CSV. (Miller can handle
|
||||
positionally-indexed data as a special case.)"""
|
||||
"""Miller operates on key-value-pair data while the familiar Unix tools operate
|
||||
on integer-indexed fields: if the natural data structure for the latter is the
|
||||
array, then Miller's natural data structure is the insertion-ordered hash map.
|
||||
This encompasses a variety of data formats, including but not limited to the
|
||||
familiar CSV. (Miller can handle positionally-indexed data as a special
|
||||
case.)"""
|
||||
])
|
||||
|
||||
print make_section('EXAMPLES', [
|
||||
|
|
@ -51,16 +58,43 @@ separator, --ors the output record separator, and --rs sets both the input and
|
|||
output separator to the given value."""
|
||||
])
|
||||
|
||||
print make_code_block(`mlr -h`)
|
||||
print make_subsection('VERB LIST', [])
|
||||
print make_code_block(`mlr --usage-list-all-verbs`)
|
||||
|
||||
print make_subsection('HELP OPTIONS', [])
|
||||
print make_code_block(`mlr --usage-help-options`)
|
||||
|
||||
print make_subsection('FUNCTION LIST', [])
|
||||
print make_code_block(`mlr --usage-functions`)
|
||||
|
||||
print make_subsection('I/O FORMATTING', [])
|
||||
print make_code_block(`mlr --usage-data-format-options`)
|
||||
|
||||
print make_subsection('SEPARATORS', [])
|
||||
print make_code_block(`mlr --usage-separator-options`)
|
||||
|
||||
print make_subsection('CSV-SPECIFIC OPTIONS', [])
|
||||
print make_code_block(`mlr --usage-csv-options`)
|
||||
|
||||
print make_subsection('DOUBLE-QUOTING FOR CSV/CSVLITE OUTPUT', [])
|
||||
print make_code_block(`mlr --usage-double-quoting`)
|
||||
|
||||
print make_subsection('NUMERICAL FORMATTING', [])
|
||||
print make_code_block(`mlr --usage-numerical-formatting`)
|
||||
|
||||
print make_subsection('OTHER OPTIONS', [])
|
||||
print make_code_block(`mlr --usage-other-options`)
|
||||
|
||||
print make_subsection('THEN-CHAINING', [])
|
||||
print make_code_block(`mlr --usage-then-chaining`)
|
||||
|
||||
# xxx do better than backtick -- trap $?
|
||||
verbs = `mlr --list-all-verbs-raw`
|
||||
print make_subsection('VERBS', [
|
||||
print make_section('VERBS', [
|
||||
""
|
||||
])
|
||||
verbs = verbs.strip.split("\n")
|
||||
for verb in verbs
|
||||
print make_subsubsection(verb, [])
|
||||
print make_subsection(verb, [])
|
||||
print make_code_block(`mlr #{verb} -h`)
|
||||
end
|
||||
|
||||
|
|
@ -76,8 +110,38 @@ end
|
|||
|
||||
# ================================================================
|
||||
def make_top()
|
||||
# xxx format the data
|
||||
".TH \"MILLER\" \"1\" \"09/14/2015\" \"\\ \\&\" \"\\ \\&\"\n"
|
||||
t = Time::new
|
||||
stamp = t.gmtime.strftime("%Y-%m-%d")
|
||||
|
||||
# Portability definitions thanks to some asciidoc output
|
||||
|
||||
"""'\\\" t
|
||||
.\\\" Title: mlr
|
||||
.\\\" Author: [see the \"AUTHOR\" section]
|
||||
.\\\" Generator: #{$0}
|
||||
.\\\" Date: #{stamp}
|
||||
.\\\" Manual: \\ \\&
|
||||
.\\\" Source: \\ \\&
|
||||
.\\\" Language: English
|
||||
.\\\"
|
||||
.TH \"MILLER\" \"1\" \"#{stamp}\" \"\\ \\&\" \"\\ \\&\"
|
||||
.\\\" -----------------------------------------------------------------
|
||||
.\\\" * Portability definitions
|
||||
.\\\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\\\" http://bugs.debian.org/507673
|
||||
.\\\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\\\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \\n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\\\" -----------------------------------------------------------------
|
||||
.\\\" * set default formatting
|
||||
.\\\" -----------------------------------------------------------------
|
||||
.\\\" disable hyphenation
|
||||
.nh
|
||||
.\\\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\\\" -----------------------------------------------------------------
|
||||
"""
|
||||
end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
|
@ -91,7 +155,6 @@ def make_section(title, paragraphs)
|
|||
end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# xxx temp
|
||||
def make_subsection(title, paragraphs)
|
||||
retval = ".SS \"#{title}\"\n"
|
||||
paragraphs.each do |paragraph|
|
||||
|
|
@ -102,7 +165,6 @@ def make_subsection(title, paragraphs)
|
|||
end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# xxx temp
|
||||
def make_subsubsection(title, paragraphs)
|
||||
retval = ".sp\n";
|
||||
retval += "\\fB#{title}\\fR\n"
|
||||
|
|
|
|||
1318
doc/mlr.1.premade
1318
doc/mlr.1.premade
File diff suppressed because it is too large
Load diff
|
|
@ -226,7 +226,7 @@ mlr sort -f hostname,uptime *.dat
|
|||
<div class="pokipanel">
|
||||
<pre>
|
||||
$ mlr --help
|
||||
Usage: mlr [I/O options] {verb} [verb-dependent options ...] {file names}
|
||||
Usage: mlr [I/O options] {verb} [verb-dependent options ...] {zero or more file names}
|
||||
Verbs:
|
||||
bar cat check count-distinct cut filter group-by group-like having-fields
|
||||
head histogram join label put regularize rename reorder sample sort stats1
|
||||
|
|
@ -831,7 +831,7 @@ Passes through input records with specified fields included/excluded.
|
|||
-f {a,b,c} Field names to include for cut.
|
||||
-o Retain fields in the order specified here in the argument list.
|
||||
Default is to retain them in the order found in the input data.
|
||||
-x|--complement Exclude, rather that include, field names specified by -f.
|
||||
-x|--complement Exclude, rather than include, field names specified by -f.
|
||||
-r Treat field names as regular expressions. "ab", "a.*b" will
|
||||
match any field name containing the substring "ab" or matching
|
||||
"a.*b", respectively; anchors of the form "^ab$", "^a.*b$" may
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue