1 module cli.options;
2 
3 import std..string;
4 import std.stdio;
5 import config;
6 import std.process;
7 import std.file;
8 
9 struct CFInfo
10 {
11 	bool create_file;
12 	immutable string default_name;
13 	immutable string filename;
14 	immutable string fullName;
15 
16 	this(bool cf, string dn, string fn)
17     {
18         create_file = cf;
19         default_name = dn;
20         filename = fn;
21         fullName = dn ~ fn;
22     }
23 }
24 
25 class CboxOptions
26 {
27 	string cboxhome = "/home/jmeireles/.cbox";
28 	CFInfo *keys;
29 	CFInfo *startup;
30 
31 	this()
32 	{
33 		keys = new CFInfo(false, this.cboxhome, "/keys");
34 		startup = new CFInfo(false, this.cboxhome, "/startup");
35 	}
36 
37 	void update()
38 	{
39 	   if (exists(this.startup.fullName)) {
40 	   	 spawnProcess(this.startup.fullName);
41 	   }
42 	}
43 
44 	/**
45  	* setup the configutation files in
46  	* home directory
47 	*/
48 	void setupConfigFiles()
49 	{
50 
51 	}
52 
53 	int parse(string[] args)
54 	{
55 		if (args.length > 1) {
56 			foreach(string arg; args) {
57 				if(arg == "-v" || arg == "-version") {
58 					return this.versions();
59 				} else if(arg == "-h" || arg == "-help") {
60 					return this.help();
61 				}
62 			}
63 		}
64 
65 		return 1;
66 	}
67 
68 private:
69 	int versions()
70 	{
71 		writeln(
72 		"Cobox-wm-"~VERSION~"\n"~
73 		"The Cteam Window Manager.\n"~
74 		"© 2015 Cbox\n"
75 		);
76 		return -1;
77 	}
78 
79 	int help()
80 	{
81 		writeln(
82 			 "Cobox-wm "~VERSION~" : (c) Cobox Team\n" ~
83                "Website: http://www.fluxbox.org/\n\n" ~
84                "-display <string>\t\tuse display connection.\n" ~
85                "-screen <all|int,int,int>\trun on specified screens only.\n" ~
86                "-rc <string>\t\t\tuse alternate resource file.\n" ~
87                "-no-slit\t\t\tdo not provide a slit.\n" ~
88                "-no-toolbar\t\t\tdo not provide a toolbar.\n" ~
89                "-version\t\t\tdisplay version and exit.\n" ~
90                "-info\t\t\t\tdisplay some useful information.\n" ~
91                "-list-commands\t\t\tlist all valid key commands.\n" ~
92                "-sync\t\t\t\tsynchronize with X server for debugging.\n" ~
93                "-log <filename>\t\t\tlog output to file.\n" ~
94                "-help\t\t\t\tdisplay this help text and exit.\n\n"
95 		);
96 		return -1;
97 	}
98 
99 }