• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

.gitignoreD22-Nov-20235 21

MakefileD22-Nov-2023443 2819

READMED22-Nov-20232.6 KiB6452

bearer.cD22-Nov-202317.5 KiB726606

bearer.hD22-Nov-2023592 237

cmdl.cD22-Nov-20232.4 KiB12891

cmdl.hD22-Nov-20231 KiB4726

link.cD22-Nov-202314.7 KiB521416

link.hD22-Nov-2023567 227

media.cD22-Nov-20236.5 KiB261206

media.hD22-Nov-2023572 227

misc.cD22-Nov-2023905 3618

misc.hD22-Nov-2023472 205

msg.cD22-Nov-20233.5 KiB171123

msg.hD22-Nov-2023658 217

nametable.cD22-Nov-20233 KiB11079

nametable.hD22-Nov-2023595 227

node.cD22-Nov-20236.2 KiB268209

node.hD22-Nov-2023567 227

peer.cD22-Nov-20232.1 KiB9468

peer.hD22-Nov-2023567 227

socket.cD22-Nov-20233.6 KiB141101

socket.hD22-Nov-2023577 227

tipc.cD22-Nov-20232.3 KiB10072

README

1DESIGN DECISIONS
2----------------
3
4HELP
5~~~~
6--help or -h is used for help. We do not reserve the bare word "help", which
7for example the ip command does. Reserving a bare word like help quickly
8becomes cumbersome to handle in the code. It might be simple to handle
9when it's passed early in the command chain like "ip addr help". But when
10the user tries to pass "help" further down this requires manual checks and
11special treatment. For example, at the time of writing this tool, it's
12possible to create a vlan named "help" with the ip tool, but it's impossible
13to remove it, the command just shows help. This is an effect of treating
14bare words specially.
15
16Help texts are not dynamically generated. That is, we do not pass datastructures
17like command list or option lists and print them dynamically. This is
18intentional. There is always that exception and when it comes to help texts
19these exceptions are normally neglected at the expence of usability.
20
21KEY-VALUE
22~~~~~~~~~
23All options are key-values. There are both drawbacks and benefits to this.
24The main drawback is that it becomes more to write for the user and
25information might seem redundant. The main benefits is scalability and code
26simplification. Consistency is important.
27
28Consider this.
291. tipc link set priority PRIO link LINK
302. tipc link set LINK priority PRIO
31
32Link might seem redundant in (1). However, if the command should live for many
33years and be able to evolve example (2) limits the set command to only work on a
34single link with no ability to extend. As an example, lets say we introduce
35grouping on the kernel side.
36
371. tipc link set priority PRIO group GROUP
382. tipc link set ??? priority PRIO group GROUP
39
402. breaks, we can't extend the command to cover a group.
41
42PARSING
43~~~~~~~
44Commands are single words. As an example, all words in "tipc link list" are
45commands. Options are key-values that can be given in any order. In
46"tipc link set priority PRIO link LINK" "tipc link set" are commands while
47priority and link are options. Meaning that they can be given like
48"tipc link set link LINK priority PRIO".
49
50Abbreviation matching works for both command and options. Meaning that
51"tipc link set priority PRIO link LINK" could be given as
52"tipc l s p PRIO l LINK" and "tipc link list" as "tipc l l".
53
54MEMORY
55~~~~~~
56The tool strives to avoid allocating memory on the heap. Most (if not all)
57memory allocations are on the stack.
58
59RETURNING
60~~~~~~~~~
61The tool could throw exit() deep down in functions but doing so always seems
62to limit the program in the long run. So we output the error and return an
63appropriate error code upon failure.
64