0.7.0 • Published 9 years ago

radic v0.7.0

Weekly downloads
47
License
MIT
Repository
github
Last release
9 years ago

radic

Travis build status NPM Version NPM Downloads Goto documentation Goto repository License

Overview

radic is the core library and application for many of my node applications.

  • It exports a variety of objects, classes and instances for external use.
  • radic is also a stand-alone application which manages global configuration and such.

How to use

Documentation

Installation

# Globally install radic for using radic command line tools
sudo npm install -g radic

# Local install into project for using libraries and helpers
npm install --save radic

Overview

ModuleDescription
configpersitent file based configuration
dbfile based database. Uses models/schemas with validation
gitlocal commands like add, commit etc. also includes API for github/bitbucket
utilextends the core util functionality with extras
ui..
clicli commands, output, input etc
netnetwork functionality, like downloading
shshell exec, execsync, execlist etc
binwrapswraps cli commands in a nice coat.
googlegoogle api functions

Basic usage

Config
var radic = require('radic'),
    Config = radic.Config,
    config = new Config('config', { /** options */ });
    
var abc = config.get('a.b.c'); 
config.set('a.b', 'c'); 
config.set('a', { b: 'c' }, true); // saves the modified configuration to file
config.del('a.b');
config.clear();
config.save(); // or this
Cli
#!/usr/bin/env node
var radic = require('radic'),
    cli = radic.cli;

cli.command('version OR version :type')
    .description('Shows current version')
    .usage('radic version minor', 'shows version')
    .method(function (cmd) {
        cli.log.info(cli.red.bold('1.0.0'));
    });
    
cli.parse(process.argv);
SH
var radic = require('radic');
var result;

// Synchronous exec
result = radic.sh.execSync('apt-cache search mono | grep develop');
console.log(result.code); console.log(result.stdout);

// Inline scripts

result = radic.sh.inlineScript('echo "hai"\n\
echo "bai" \n\
echo "draai"');
console.log(result.code);
console.log(result.stdout);

result = radic.sh.inlineScript(function(){/*
       echo "hai"
       echo "bai"
       echo "draai"
       #apt-cache search mono
*/});
console.log(result.code);
console.log(result.stdout);
Net
var radic = require('radic');
radic.net.download('http://download.gigabyte.ru/driver/mb_driver_marvell_bootdisk_w7w8.exe', __dirname, { /* options */ }, function(){
    // optional callback to make function execute asynchronously
});
Binwraps
var radic = require('radic');    
var binwraps = radic.binwraps;

binwraps.createBinWrap('VBoxManage');
     
var vbox = binwraps.vboxmanage;
var result = vbox('createvm', {
  name: ops.name,
  ostype: 'Debian_64',
  basefolder: path.resolve(process.cwd()),
  register: true
});
console.log(result.stdout, result.code);


binwraps.autoSyncExec = false;
vbox('createvm', {
  name: ops.name,
  ostype: 'Debian_64',
  basefolder: path.resolve(process.cwd()),
  register: true
}, function(){
     // callllback
});


var commands = binwraps.getCommands();
binwraps[ commands[0] ]('arg', { weed: 'bad' }); // just an example..
DB

File based database

var db = new require('radic').DB('myfileDB4', {
    path: 'HOMEDIR/.radic/stores',
    ext: '.db',
    onLoaded: function(){}
});

var user = db.model('user', {
    type: 'object',
    properties: {
        username: { type: 'string', eq: 'ipsum' },
        email: { type: 'string', eq: 'ipsum' },
        password: {
            type: 'array',
            items: { type: 'number' }
        }
    }
});

License

Copyright 2014 Robin Radic

MIT Licensed