aboutsummaryrefslogtreecommitdiff
path: root/tools/upgrade.nom
blob: 8f478aca16adb570e2f3fe5aa35a73d899bf9d55 (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
#!/usr/bin/env Nomsu -V2.4.4.3
use "core"
use "compatibility"
use "lib/os.nom"

%args = (command line args)
%inplace = (no)
if (%args.1 is "-i"):
    %inplace = (yes)
    remove index 1 from %args
if (%args.1 is "-t"):
    use "lib/consolecolor.nom"
    %test = (yes)
    remove index 1 from %args
for %path in %args:
    if (%path is "-i"): %inplace = (yes)
    for file %filename in %path:
        %tree = (parse (read file %filename) from %filename)
        %uptree = (%tree upgraded from %tree.version to (Nomsu version))
        %text = "#!/usr/bin/env nomsu -V\(Nomsu version)\n\(%uptree as nomsu)"
        if:
            %inplace:
                say "Upgraded \%filename"
                write %text to file %filename
            %test:
                if (%uptree == %tree):
                    say (dim "\%filename will not be changed")
                ..else:
                    say (bright "\%filename will be changed")
            else:
                say %text