aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
blob: 731da47b0812a8d5c93cedeb71094ca555f5b355 (plain) (blame)
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
#include <stdio.h>
#include <readline/readline.h>
#include <unistd.h>
#include <stdlib.h>
#include <getopt.h>

#include "login.h"
#include "util.h"
#include "post.h"

/* prints usage */

void
usage(const char *progname)
{
	printf("Usage: %s -s=status [-v=visibility]\n",progname);
	return;
}
/* prints a string to stderr */

void
eputs(const char *s) {
	fprintf(stderr,"%s\n",s);
}

int
main(int argc, char **argv)
{
	if(access(".demiurgerc", F_OK ))
		setup();
	int c;
	char *status = NULL;
	char *visibility = NULL;
	
	if(argc == 1) {
		usage(argv[0]);
		return -1;
	}
	
	while((c = getopt(argc,argv,"s:v:")) != -1) {
		switch(c) {
		case 's':
			status = optarg;
			break;
		case 'v':
			visibility = optarg;
			break;
		}
	}
	if(status == NULL) {
		eputs("Enter a status (-s)");
		return -1;
	}
	
	if(visibility == NULL) {
		visibility = "public";
	}
	
	post_status(status,visibility);

}