A basic demo of using getopt to parse command-line options.
(demo-p x) is a std::defaggregate of the following fields.
- help — Print a help message and exit with status 0.
Invariant (booleanp help).
- verbose — Turn on excessive debugging information.
Invariant (booleanp verbose).
- version — Print version information and exit with status 0.
Invariant (booleanp version).
- username — Change the username to something else.
Invariant (stringp username).
- port — Port to connect to.
Invariant (natp port).
- dirs — Directory list.
Invariant (string-listp dirs).
- extra-stuff — Hidden option that the user never sees, but that is part of
- extra-stuff2 — Hidden option that the user never sees, but that is part of
Invariant (stringp extra-stuff2).
Source link: demo-p
This is a basic demo of how to use getopt, and a collection of unit
tests to make sure getopt is working correctly.
Note: our focus in this demo is just on the command-line parsing piece. We
illustrate illustrates a lot of the things you can do with getopt, e.g., short
aliases, long names, default values, validating inputs, and accumulating
arguments. But we don't turn it into a working program. If you want to
understand how getopt and argv and save-exec fit together,
This defoptions call does two things:
- It introduces demo-p, an ordinary std::defaggregate with
various fields and well-formedness conditions. These demo-p structures
can be passed around throughout your program just like any ordinary ACL2
- It introduces parse-demo, a function that can parse a command-line
into a demo-p. The command-line is represented as a list of strings; see
for instance argv to understand how to get the command-line
arguments given to ACL2.
- Parse arguments from the command line into a demo-p aggregate.
- Raw constructor for demo-p structures.
- Constructor macro for demo-p structures.
- A copying macro that lets you create new demo-p structures, based on existing structures.
- Raw constructor for honsed demo-p structures.
- Constructor macro for honsed demo-p structures.
- Automatically generated usage message.
- Access the version field of a demo-p structure.
- Access the verbose field of a demo-p structure.
- Access the username field of a demo-p structure.
- Access the port field of a demo-p structure.
- Access the help field of a demo-p structure.
- Access the extra-stuff2 field of a demo-p structure.
- Access the extra-stuff field of a demo-p structure.
- Access the dirs field of a demo-p structure.