aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/readcons.c
blob: f0f8397f084e0941d0e8c38501717796080a75f9 (plain)
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
#include <u.h>
#include <libc.h>

void
usage(void)
{
	fprint(2, "usage: readcons [-s] [-d default] prompt\n");
	exits("usage");
}

void
main(int argc, char **argv)
{
	char *def, *p;
	int secret;
	
	def = nil;
	secret = 0;
	ARGBEGIN{
	case 's':
		secret = 1;
		break;
	case 'd':
		def = EARGF(usage());
		break;
	default:
		usage();
	}ARGEND
	
	if(argc != 1)
		usage();

	p = readcons(argv[0], def, secret);
	if(p == nil)
		exits("readcons");
	print("%s\n", p);
	exits(0);
}