Command line tool to duplicate/modify version number strings across source code and distribution files according to syntax context.

⌈⌋ branch:  version numbers get/write


Check-in [6b2d027406]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Allow reading Version: from .deb archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:6b2d02740608b26b6d847c40d59a7cb50443e345
User & Date: mario 2014-02-09 00:35:23
Context
2014-02-10
00:36
Escape shell arg for ar|tar .deb reading check-in: a9910f4ee2 user: mario tags: trunk
2014-02-09
00:35
Allow reading Version: from .deb archive check-in: 6b2d027406 user: mario tags: trunk
2014-02-08
23:24
Moved data/regex into cfg{} check-in: 789c1a3df8 user: mario tags: trunk
Changes

Changes to version.php.

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
...
136
137
138
139
140
141
142

143
144
145
146
147
148
149
...
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
...
484
485
486
487
488
489
490

















491
492
493
494
495
496
497
 *    VERSION=$(version get orig.c ++)
 *    version write $VERSION dest.cpp
 *
 * There's no commandline option for custom regexen, to eschew code duplication
 * in said shell scripts.
 *
 *@version 3.2.2-0
 */               



// Tool-specific data
class cfg {

 
................................................................................
        "any" => array("debian","rpmspec","plugin","docblock","const","define","var","wordpress","ini","python","composer","xmltag"),
    );


    // Binary file format handlers (see action:: class)
    static $bin_handlers = array(
        "phar" => "bin_phar",

    );


    // Command line aliases
    static $action_aliases = array (
        "write" => "write",  "save" => "write",  "update" => "write",
        "get" => "get",  "from" => "get",
................................................................................
        // Read and print from file
        case "get":
            if ($cmd->file) {
                action::read($cmd);
                if (!rx::is_valid_ver($cmd->version)) {
                    // return 0.0-0error on failure
                    fwrite(STDOUT, "0.0-0error");
                    error("No version number found in file '$this->file'", 61/*ENODATA*/);
                    // (while --read should not not)
                }
                print $cmd->version;
                $last=$cmd and $cmd=new command();
            }
            break;

................................................................................
        else {
            $m["version"] = $cmd->version;
            $p->setMetadata($m);
        }
        // same as:
        //    phar meta-get -f filename.phar -k version
    }


















}




/**







|







 







>







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
...
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
...
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
 *    VERSION=$(version get orig.c ++)
 *    version write $VERSION dest.cpp
 *
 * There's no commandline option for custom regexen, to eschew code duplication
 * in said shell scripts.
 *
 *@version 3.2.2-0
 */         



// Tool-specific data
class cfg {

 
................................................................................
        "any" => array("debian","rpmspec","plugin","docblock","const","define","var","wordpress","ini","python","composer","xmltag"),
    );


    // Binary file format handlers (see action:: class)
    static $bin_handlers = array(
        "phar" => "bin_phar",
        "deb" => "bin_deb",
    );


    // Command line aliases
    static $action_aliases = array (
        "write" => "write",  "save" => "write",  "update" => "write",
        "get" => "get",  "from" => "get",
................................................................................
        // Read and print from file
        case "get":
            if ($cmd->file) {
                action::read($cmd);
                if (!rx::is_valid_ver($cmd->version)) {
                    // return 0.0-0error on failure
                    fwrite(STDOUT, "0.0-0error");
                    error("No version number found in file '$cmd->file'", 61/*ENODATA*/);
                    // (while --read should not not)
                }
                print $cmd->version;
                $last=$cmd and $cmd=new command();
            }
            break;

................................................................................
        else {
            $m["version"] = $cmd->version;
            $p->setMetadata($m);
        }
        // same as:
        //    phar meta-get -f filename.phar -k version
    }
    
    
    
    // .deb archives (read-only)
    function bin_deb($cmd) {
    
        if (empty($cmd->version)) {
            $src = `ar p {$cmd->file} control.tar.gz | tar xOz ./control`;
            $rx = rx::combine(array(cfg::$rx_format["debian"]));
            if (preg_match($rx[0], $src, $m)) {
                $cmd->version = $m["version"];
            }
        }
        else {
            error("Cannot update .deb archives.", 1 /*EPERM*/);
        }
    }

}




/**