CSTARS / farm-budgets-app

Application for calculating farm budgets
1 stars 0 forks source link

Develop a plan for a command-line interface #18

Closed qjhart closed 7 years ago

qjhart commented 9 years ago

The Farm-Budget App has become the best tool for the creation of new budgets, materials and prices. However, that implies that we also need a method for scripting the creation of new items, in the case where we are converting data from one format to the budgets (for example from NASS data). Ideally this should work both in the browser and on a server. I envision the following type of interaction...

//$ node 
var budgetdb = require('farm-budget-app')({"db":{"type":"mongo", "dbi":"locahost:3000"}});
// Or some ES6 server/browser equiv

budgetdb.listAuthorities()
{
 "https://github.com/CSTARS/farm-budgets-data/tree/master/ahb": "Maybe a description here",
 "https://github.com/CSTARS/farm-budgets-data/tree/master/nass": "Maybe a description here",
 ...
}

var farm=budgetdb.newFarm(
 {name:"test",size:100,unit:"[acr_us]",
  location:"06102",
  commodity:"ALFALFA"});

var plant=farm.addOperation({name:"planting"});
plant.addToSchedule('2014-04-01','1 mon');
plant.addMaterial('Labor--Equipment Operator',100,'h');
plant.addMaterial('fubar',100,'h');

farm.addAuthority(["https://github.com/CSTARS/farm-budgets-data/tree/master/ahb"])
farm.getMaterialList()
{
 'Labor--Equipment Operator': { "description":"Standard Operator","unit":"h"},
 'fubar':{"err":"Not Found"}
}

farm.getPriceList()
{
 "Labor--Equipment  Operator":{price:30,unit:"us$/h","location":"CA" }
}

farm.getBudget();
{
  cost: 314000,
  unit: "us$",
  start: '2014-04-01',
  end: '2016-12-01',
  operations: [ {name:"planting", cost_per: "15000",unit:"us$","total":15000},
                       {} ],
  materials: [
   {name:"Labor--Equipment Operator", "amount":90,unit:"h","price": { amount:30, unit:"us$ per h" } },
   {} ]
}
jrmerz commented 9 years ago

So do you want command line utilities or just models that work as you have described above? I have started a simple command line utility that lets you interact with any models function. More info can be found here: https://github.com/CSTARS/farm-budgets-app/tree/master/lib/cmd

jrmerz commented 8 years ago

The farm budget SDK has been started: https://github.com/CSTARS/farm-budgets-sdk. Much to do, but all of the basic API calls are there.