File: arguments

package info (click to toggle)
icmake 13.05.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,132 kB
  • sloc: cpp: 11,595; fortran: 883; makefile: 853; sh: 546; pascal: 342
file content (88 lines) | stat: -rw-r--r-- 2,590 bytes parent folder | download | duplicates (3)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
void arguments(int argc, list argv)
{
    list icm = getenv("ICM");           // ICM environment var defined?

    if ((int)icm[0] == 1)                
        g_skelPath = icm[1];            // then re-assign skelPath

    int cmdidx = 1;
    while (cmdidx < argc)
    {
        string arg = argv[cmdidx];

        if (arg[0] != "-")              // no (more) options
            break;

        if (arg[1] == "b")              // -b: basic installation
        {
            g_basic = 1;
            g_version = 0;
        }
        else if (arg[1] == "c")         // -c: re-assign g_confPath
        {
            arg = substr(arg, 2, 999);  // get all beyond -c

            if (arg == "")              // or get then next argument
            {
                if (cmdidx == argc)
                    quit("-c lacks configuration file specification");

                arg = argv[++cmdidx];
            }
            g_confPath = absPath(arg);  // reassign confpath
        }
        else if (arg[1] == "d")         // -d: debug
            g_debug = 1;
        else if (arg[1] == "I")         // -I: no skeletons
            g_skeletons = 0;
        else if (arg[1] == "r")         // -r: replace existing file(s)
        {
            g_askReplace = 0;
            g_replace = 1;
        }
        else if (arg[1] == "s")         // -s: re-assign g_skelPath
        {
            arg = substr(arg, 2, 999);  // get all beyond -s

            if (arg == "")              // or get then next argument
            {
                if (cmdidx == argc)
                    quit("-s lacks skeleton dir specification");

                arg = argv[++cmdidx];
            }
            g_skelPath = arg;           // reassign skelPath
        }
        else
            quit("Option `" + arg + "' not supported\n");

        ++cmdidx;
    }

    g_skelPath = absPath(g_skelPath);
    g_destSpec = argv[cmdidx];
    g_destPath = absPath(g_destSpec);

    g_icmconf = g_destPath + "icmconf";

    if (++cmdidx < argc)
    {
        g_defaultCommandArg = argv[cmdidx];

        if (listfind(g_defaultCommands, g_defaultCommandArg) == -1)
        {
            printf("Initial command `", g_defaultCommandArg, 
                                                        "' not supported\n");
            exit(1);
        }

        if (g_defaultCommandArg == "library")
            g_version = 0;

        g_defaultCommand = 
                "\n"
                "#define DEFCOM     \"" + g_defaultCommandArg + "\"\n";
    }

    md(g_destPath);                       // install the target dir
}