|
Packit Service |
3880ab |
DESIGN DECISIONS
|
|
Packit Service |
3880ab |
----------------
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
HELP
|
|
Packit Service |
3880ab |
~~~~
|
|
Packit Service |
3880ab |
--help or -h is used for help. We do not reserve the bare word "help", which
|
|
Packit Service |
3880ab |
for example the ip command does. Reserving a bare word like help quickly
|
|
Packit Service |
3880ab |
becomes cumbersome to handle in the code. It might be simple to handle
|
|
Packit Service |
3880ab |
when it's passed early in the command chain like "ip addr help". But when
|
|
Packit Service |
3880ab |
the user tries to pass "help" further down this requires manual checks and
|
|
Packit Service |
3880ab |
special treatment. For example, at the time of writing this tool, it's
|
|
Packit Service |
3880ab |
possible to create a vlan named "help" with the ip tool, but it's impossible
|
|
Packit Service |
3880ab |
to remove it, the command just shows help. This is an effect of treating
|
|
Packit Service |
3880ab |
bare words specially.
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
Help texts are not dynamically generated. That is, we do not pass datastructures
|
|
Packit Service |
3880ab |
like command list or option lists and print them dynamically. This is
|
|
Packit Service |
3880ab |
intentional. There is always that exception and when it comes to help texts
|
|
Packit Service |
3880ab |
these exceptions are normally neglected at the expence of usability.
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
KEY-VALUE
|
|
Packit Service |
3880ab |
~~~~~~~~~
|
|
Packit Service |
3880ab |
All options are key-values. There are both drawbacks and benefits to this.
|
|
Packit Service |
3880ab |
The main drawback is that it becomes more to write for the user and
|
|
Packit Service |
3880ab |
information might seem redundant. The main benefits is scalability and code
|
|
Packit Service |
3880ab |
simplification. Consistency is important.
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
Consider this.
|
|
Packit Service |
3880ab |
1. tipc link set priority PRIO link LINK
|
|
Packit Service |
3880ab |
2. tipc link set LINK priority PRIO
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
Link might seem redundant in (1). However, if the command should live for many
|
|
Packit Service |
3880ab |
years and be able to evolve example (2) limits the set command to only work on a
|
|
Packit Service |
3880ab |
single link with no ability to extend. As an example, lets say we introduce
|
|
Packit Service |
3880ab |
grouping on the kernel side.
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
1. tipc link set priority PRIO group GROUP
|
|
Packit Service |
3880ab |
2. tipc link set ??? priority PRIO group GROUP
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
2. breaks, we can't extend the command to cover a group.
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
PARSING
|
|
Packit Service |
3880ab |
~~~~~~~
|
|
Packit Service |
3880ab |
Commands are single words. As an example, all words in "tipc link list" are
|
|
Packit Service |
3880ab |
commands. Options are key-values that can be given in any order. In
|
|
Packit Service |
3880ab |
"tipc link set priority PRIO link LINK" "tipc link set" are commands while
|
|
Packit Service |
3880ab |
priority and link are options. Meaning that they can be given like
|
|
Packit Service |
3880ab |
"tipc link set link LINK priority PRIO".
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
Abbreviation matching works for both command and options. Meaning that
|
|
Packit Service |
3880ab |
"tipc link set priority PRIO link LINK" could be given as
|
|
Packit Service |
3880ab |
"tipc l s p PRIO l LINK" and "tipc link list" as "tipc l l".
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
MEMORY
|
|
Packit Service |
3880ab |
~~~~~~
|
|
Packit Service |
3880ab |
The tool strives to avoid allocating memory on the heap. Most (if not all)
|
|
Packit Service |
3880ab |
memory allocations are on the stack.
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
RETURNING
|
|
Packit Service |
3880ab |
~~~~~~~~~
|
|
Packit Service |
3880ab |
The tool could throw exit() deep down in functions but doing so always seems
|
|
Packit Service |
3880ab |
to limit the program in the long run. So we output the error and return an
|
|
Packit Service |
3880ab |
appropriate error code upon failure.
|