Menu

Supplying a config (file location) on the CLI

Help
2009-05-26
2013-09-15
  • Rowan van der Molen

    I like weex and I often use it for uploading websites when I only have FTP access (otherwise, I normally use rsync).

    All my websites' files live in version management, with checkouts on multiple machines (of different colleagues). What I would like is if I could keep the weex config (and cache, if possible) in the project dir.

    Is it possible to specify to weex where it should look for its config file?

     
  • Anonymous

    Anonymous - 2010-12-29

    It is possible to modify a bit the source code to permit the specification of a weex "home directory" (instead of ~/.weex) where the files weexrc, weex.cache.* and weex.log would be read/created. I think this would address the issue and it can be quite easily done.

    Here is a quick'n dirty howto :

    1. In src/weex.c, add a command line option like (on line 58 in example) :

    { 'w', "whome",        OPT_STRING, &whome,         0            },
    

    2. In src/variable.h add the global variable "whome" to hold the specified weex home directory. In example on line 85 :

    GLOBAL char *whome;
    

    3. In src/config.c, modify function config_location(void) , line 85:

    if (whome) temp=str_concat(whome,"/weexrc",NULL);
    else temp=str_concat(getenv("HOME"),"/.weex/weexrc",NULL);
    

    4. In src/cache.c modify function load_cache(void) , line 59 :

    if (whome) temp=str_concat(whome,"/weex.cache.",cfgSectionNumberToName(host_number),NULL);
    else temp=str_concat(getenv("HOME"),"/.weex/weex.cache.",cfgSectionNumberToName(host_number),NULL);
    

    5. In src/log.c modify function *log_open(void), line 79 :

    if (whome) {
         log_file=str_concat(whome,"/weex.log",NULL);
         lock_file=str_concat(whome,"/.lock",NULL);
    } else {
         log_file=str_concat(getenv("HOME"),"/.weex/weex.log",NULL);
         lock_file=str_concat(getenv("HOME"),"/.weex/.lock",NULL);      
    }
    

    6. You are done ! You can now try :

    ./configure
    make
    src/weex -w path/to/my/weex/dir MyConfig
    

    Cheers

     
  • Anonymous

    Anonymous - 2010-12-29

    Something is missing, I forgot that the .lock file should also be removed ^^

    5b. in src/log.c modify function log_close(FILE *fp), line 131 (after mod #5) :

    if (whome) lock_file=str_concat(whome,"/.lock",NULL);
    else lock_file=str_concat(getenv("HOME"),"/.weex/.lock",NULL);
    

    and.. weepee it's working !

     
  • txemi

    txemi - 2013-09-15

    I also would like to specify conffile from command line. I keep websites in code repositories and I also would like to keep weex conffile this way. Having to copy this file to user home in different machines and update it on each change and merge serveral weex conffiles when working with more than one project is a little annoying.

    Thanks,
    txemi

     

Log in to post a comment.