File: help.c

package info (click to toggle)
librnd 4.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,812 kB
  • sloc: ansic: 126,990; sh: 2,602; makefile: 2,145; awk: 7
file content (90 lines) | stat: -rw-r--r-- 2,572 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

static const char *help[] = {
	"dump", "native",
	"Dump all settings as ended up in the native database after the last merge/udpate.",

	"dump", "lihata role",
	"Dump all in-memory lihata settings of a given role. For roles, see: help roles",

	"load", "role filename",
	"Load a lihata file as role",

	"load", "*",
	"Load all roles from disk - the same way as it happens on a normal pcb-rnd startup.",

	"paste", "role lhttxt",
	"Paste in-line lihata document lhttxt as role, like if it was loaded from a file",

	"policy", "pol",
	"Change current set-policy to pol. This only affects whether a set command inserts, appends or overwrites list-type settings. For valid policies, see: help policies",

	"role", "rol",
	"Change current set-policy to rol. This only affects the destination of subsequent set commands. For valid roles, see: help roles",

	"chprio", "prio",
	"Change the priority of the first confroot of the current role's in-memory lihata document to prio and merge. Prio is an integer value.",

	"chpolicy", "pol",
	"Change the policy of the first confroot of the current role's in-memory lihata document to pol and merge. Pol is a policy, see: help policies",

	"set", "path value",
	"Call rnd_conf_set() on a given path with the given value, using the current set-role and the current set-policy. See also: help role; help policy.",

	"watch", "path",
	"Announce changes of a given path. See also: help unwatch",

	"unwatch", "path",
	"Stop announcing changes of a given path. See also: help watch",

	"notify", "on",
	"Turn on global notification on config changes.",

	"notify", "off",
	"Turn off global notification on config changes.",

	"echo", "text...",
	"Print multi-word text.",

	"reset", "role",
	"Reset (make empty) the in-memory lihata document of role; see also: help roles",

	"reset", "*",
	"Reset (make empty) all in-memory lihata documents",

/* misc */
	"roles", NULL,
	"Valid roles: system, defaultpcb, user, env, project, design, cli",

	"policies", NULL,
	"Valid policies: prepend, append, overwrite",

	NULL, NULL, NULL
};

void cmd_help(char *arg)
{
	const char **s;

	printf("\n");

	if (arg == NULL) {
		const char *last = "";
		printf("Try help topic. Available topics:\n");
		for(s = help; s[2] != NULL; s+=3) {
			if (strcmp(last, s[0]) != 0)
				printf("  %s\n", s[0]);
			last = s[0];
		}
		return;
	}

	for(s = help; s[2] != NULL; s+=3) {
		if (strcmp(arg, s[0]) == 0) {
			printf("%s %s\n", s[0], (s[1] == NULL ? "" : s[1]));
			printf("%s\n\n", s[2]);
		}
	}
}