Skip to content

davglass/yogi-foo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

yogi sub commands

Example script to show how to create a yogi sub command.

Create any script named yogi-xxx, make it executible and place it in your path. Now xxx can be used as a yogi sub command.

This can be anything that's executible, a bash script, a php script, anything.

The power comes if you write a node.js script:

Example

yogi will export an evironment variable called YOGI_PATH to tell the sub command where yogi is at on the file system.

At that point you can require any part of yogi you want so that you can use it's internal tools.

This very simple example shows that logging and the built in config objects work.

var YOGI_PATH = process.env.YOGI_PATH,
    path = require('path');

if (!YOGI_PATH) {
    console.log('This should be executed from yogi');
    process.exit(1);
}

var args = require(path.join(YOGI_PATH, 'lib/args'));
var log = require(path.join(YOGI_PATH, 'lib/log'));
var config = require(path.join(YOGI_PATH, 'lib/config'));

var options = args.parse();
config.init(options);

log.info('foo command here');
log.info('you are logged in as: ' + config.get('username'));

About

Example of a yogi sub command

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published