aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp59
1 files changed, 54 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 132fb18..70a3ffc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,16 +1,65 @@
1#include "builder.h" 1#include "builder.h"
2#include "viewerplain.h" 2#include "viewerplain.h"
3#include "viewerpercent.h" 3#include "viewerpercent.h"
4#include "paramproc.h"
5#include "staticstring.h"
6
7class Param : public ParamProc
8{
9public:
10 Param() :
11 sFile("build.conf")
12 {
13 addHelpBanner("Build r?\n\n");
14 addParam("file", 'f', &sFile,
15 "Set the input script, default: build.conf");
16 addParam('p', mkproc(Param::procViewPercent),
17 "Switch to percent view.");
18 addParam("help", mkproc(ParamProc::help),
19 "This help");
20 pViewer = new ViewerPlain;
21 }
22
23 virtual ~Param()
24 {
25 delete pViewer;
26 }
27
28 virtual int cmdParam( int argc, char *argv[] )
29 {
30 if( sAction > 0 )
31 {
32 printf("You can only specify one action per command line.\n\n");
33 exit( 1 );
34 }
35 sAction = argv[0];
36 return 1;
37 }
38
39 int procViewPercent( int argc, char *argv[] )
40 {
41 delete pViewer;
42 pViewer = new ViewerPercent;
43 }
44
45 std::string sFile;
46 StaticString sAction;
47 Viewer *pViewer;
48
49private:
50};
4 51
5int main( int argc, char *argv[] ) 52int main( int argc, char *argv[] )
6{ 53{
7 ViewerPercent p; 54 Param prm;
8 Builder bld( p ); 55 prm.process( argc, argv );
56
57 Builder bld( *prm.pViewer );
9 58
10 bld.load("build.conf"); 59 bld.load( prm.sFile.c_str() );
11 60
12 if( argc >= 2 ) 61 if( prm.sAction > 0 )
13 bld.build( argv[1] ); 62 bld.build( prm.sAction );
14 else 63 else
15 bld.build(); 64 bld.build();
16/* 65/*