#!/usr/bin/env python

import sys
sys.path.append('..')

from cli import *
from optparse import OptionParser

parse = OptionParser()
parse.add_option('-a', '--variable', dest='variables',
                 help='Add variable',
                 default=[], action='append', type=str)
parse.add_option('-r', '--random', dest='randoms',
                 help='Add random (is_var=0)',
                 default=[], action='append', type=str)

o = parse.parse_args()[0]

for var in o.variables:
    exists = session.query(Variable).filter(Variable.name == var).first()
    if exists is not None:
        print '%s already exists!' % var
        exit()

    v = Variable(var, 1)
    session.add(v)

for var in o.randoms:
    exists = session.query(Variable).filter(Variable.name == var).first()
    if exists is not None:
        print '%s already exists!' % var
        exit()

    v = Variable(var, 0)
    session.add(v)

session.commit()

@@ -189,33 +189,32 @@
                 
- 
 help='Add variab
@@ -218,17 +218,16 @@
 iable',%0A
- 
         
@@ -332,33 +332,32 @@
                 
- 
 help='Add random
@@ -370,17 +370,16 @@
 ar=0)',%0A
- 
         
@@ -429,34 +429,242 @@
 tr)%0A
-%0Ao = parse.parse_args()%5B0%5D
+parse.add_option('-l', '--list', dest='list_vars',%0A                default=False, action='store_true')%0A%0Ao = parse.parse_args()%5B0%5D%0A%0Aif o.list_vars:%0A    vars = session.query(Variable).all()%0A    for x in vars:%0A        print x%0A%0A    exit()
 %0A%0Afo

Add --list to variable tool.