]> git.sur5r.net Git - ngadmin/blob - cli/com_tree.c
Let commands handle themselves absence of arguments
[ngadmin] / cli / com_tree.c
1
2 #include "commands.h"
3
4
5 static void display_node (const struct TreeNode *tn, int depth)
6 {
7         int i;
8         const struct TreeNode *s;
9         
10         
11         for (i = 0; i < depth; i++)
12                 putchar('\t');
13         puts(tn->name);
14         
15         if (tn->sub == NULL)
16                 return;
17         
18         for (s = tn->sub; s->name != NULL; s++)
19                 display_node(s, depth + 1);
20 }
21
22
23 bool do_tree (int argc, const char **argv UNUSED, struct ngadmin *nga UNUSED)
24 {
25         if (argc > 0) {
26                 printf("this command takes no argument\n");
27                 return false;
28         }
29         
30         display_node(&commands, 0);
31         
32         return true;
33 }
34
35