]> git.mdlowis.com Git - archive/bci.git/commitdiff
Added bci based on usage.txt
authorMike D. Lowis <mike@mdlowis.com>
Sun, 4 Mar 2012 16:46:17 +0000 (11:46 -0500)
committerMike D. Lowis <mike@mdlowis.com>
Sun, 4 Mar 2012 16:46:17 +0000 (11:46 -0500)
bci [new file with mode: 0644]
usage.txt

diff --git a/bci b/bci
new file mode 100644 (file)
index 0000000..9a7531b
--- /dev/null
+++ b/bci
@@ -0,0 +1,71 @@
+#!/bin/env bash
+
+BCI_HOME=$HOME/.bci
+
+function bci-usage(){
+cat << EOF
+Usage: bci [command] [options]
+
+Valid commands:
+    add    <name> <url>    Adds a project to bci
+    del    <name>          Deletes a project from bci
+    ls     <name>          Lists all projects
+    update <name>          Force a pull on the specified project
+    build  <name>          Force a build on the specified project
+EOF
+exit 1
+}
+
+function bci-add(){
+    local proj_name=$2
+    : ${proj_name:?"No project name provided."}
+    local proj_url=$3
+    : ${proj_name:?"No project url provided."}
+    local PROJ_HOME="$BCI_HOME/projects/$proj_name"
+    mkdir -p "$PROJ_HOME"
+    mkdir -p "$PROJ_HOME/data"
+    git clone $proj_url $PROJ_HOME/repo
+    echo "# put any project specific bci configuration options in this file" >> "$PROJ_HOME/config"
+    read -p"how should the project be built? " BUILDCMD
+    echo "build_command='$BUILDCMD'" >> "$PROJ_HOME/config"
+    echo "project successfully created at $PROJ_HOME"
+}
+
+function bci-del(){
+    local proj_name=$2
+    : ${proj_name:?"No project name provided."}
+    rm -rf "$BCI_HOME/projects/$proj_name"
+}
+
+function bci-ls(){
+    ls "$BCI_HOME/projects"
+}
+
+function bci-update(){
+    local proj_name=$2
+    : ${proj_name:?"No project name provided."}
+    pushd "$BCI_HOME/projects/$proj_name/repo"
+    git pull
+    popd
+}
+
+function bci-build(){
+    local proj_name=$2
+    : ${proj_name:?"No project name provided."}
+    pushd "$BCI_HOME/projects/$proj_name/repo"
+    source "$BCI_HOME/projects/$proj_name/config" #this must contain build_command=...
+    : ${build_command:?"don't know how to build this project"}
+    $build_command
+    popd
+}
+
+case "$1" in
+    add) bci-add $* ;;
+    del) bci-del $* ;;
+    ls) bci-ls $* ;;
+    update) bci-update $* ;;
+    build) bci-build $* ;;
+
+    help) bci-usage ;;
+    '') bci-usage ;;
+esac
index aa159af05c14703746b43b0069759b03d8f5d2b1..3f7bac2be9abbda53e593f5030b0edd07fdea4b9 100644 (file)
--- a/usage.txt
+++ b/usage.txt
@@ -3,91 +3,91 @@ Usage information for bci
 BCI will be used to build projects as they are committed in git
 
 general bci commands
-       bci help
-               display usage information
+    bci help
+        display usage information
 commands to manage list of projects:
-       bci add <name> <git repository location>
-               create a bci project named <name> that will live in $BCI_HOME/projects/<name>
-               $ PROJ_HOME="$BCI_HOME/projects/<name>"
-               $ mkdir -p "$PROJ_HOME"
-               $ mkdir -p "$PROJ_HOME/data"
-               $ git clone <git repository location> $PROJ_HOME/repo
-               $ echo "# put any project specific bci configuration options in this file" >> "$PROJ_HOME/config"
-               $ echo "project successfully created at $PROJ_HOME"
-               $ read -p"how should the project be built? " BUILDCMD
-               $ echo "build_command=$BUILDCMD" >> "$PROJ_HOME/config"
-       bci del <name> 
-               delete the project named <name>
-               $ #todo: add a prompt (eventually using QBALL_YES_NO_PROMPT, or just a simple "Y/N")
-               $ rm -rf "$BCI_HOME/projects/<name>"
-       bci ls (TODO: [expression])
-               list all projects (TODO: that match an optional expression)
-               $ ls "$BCI_HOME/projects"
+    bci add <name> <git repository location>
+        create a bci project named <name> that will live in $BCI_HOME/projects/<name>
+        $ PROJ_HOME="$BCI_HOME/projects/<name>"
+        $ mkdir -p "$PROJ_HOME"
+        $ mkdir -p "$PROJ_HOME/data"
+        $ git clone <git repository location> $PROJ_HOME/repo
+        $ echo "# put any project specific bci configuration options in this file" >> "$PROJ_HOME/config"
+        $ echo "project successfully created at $PROJ_HOME"
+        $ read -p"how should the project be built? " BUILDCMD
+        $ echo "build_command=$BUILDCMD" >> "$PROJ_HOME/config"
+    bci del <name>
+        delete the project named <name>
+        $ #todo: add a prompt (eventually using QBALL_YES_NO_PROMPT, or just a simple "Y/N")
+        $ rm -rf "$BCI_HOME/projects/<name>"
+    bci ls (TODO: [expression])
+        list all projects (TODO: that match an optional expression)
+        $ ls "$BCI_HOME/projects"
 commands to manage a specific project
-       bci update <name>
-               force a pull of the specified project
-               TODO: create an alias for this command, bci pull <name>
-               $ pushd "$BCI_HOME/projects/<name>/repo"
-               $ git pull
-               $ popd
-       bci build <name>
-               force a bulid of the specified project
-               note: this does not implicity update
-               $ pushd "$BCI_HOME/projects/<name>/repo"
-               $ source "$BCI_HOME/projects/<name>/config" #this must contain build_command=...
-               $ : ${build_command:?"don't know how to build this project"}
-               $ $(build_command)
-       TODO: be nice if something like this were to exist at some point
-               bci config <name> <prop-name> <prop-value>
-                       set config option for a bci project named <name>
-       TODO: introduce mechanism to make <name> implicit and thus optional
-               ideas:
-                       specify a $BCI_PROJ_HOME env var
-                       check if $(pwd) is a valid bci project home
-                       sacrifice a goat
+    bci update <name>
+        force a pull of the specified project
+        TODO: create an alias for this command, bci pull <name>
+        $ pushd "$BCI_HOME/projects/<name>/repo"
+        $ git pull
+        $ popd
+    bci build <name>
+        force a bulid of the specified project
+        note: this does not implicity update
+        $ pushd "$BCI_HOME/projects/<name>/repo"
+        $ source "$BCI_HOME/projects/<name>/config" #this must contain build_command=...
+        $ : ${build_command:?"don't know how to build this project"}
+        $ $(build_command)
+    TODO: be nice if something like this were to exist at some point
+        bci config <name> <prop-name> <prop-value>
+            set config option for a bci project named <name>
+    TODO: introduce mechanism to make <name> implicit and thus optional
+        ideas:
+            specify a $BCI_PROJ_HOME env var
+            check if $(pwd) is a valid bci project home
+            sacrifice a goat
 
 
 installation:
-       config option required is $BCI_HOME
-       this is a place place for bci to store its config options, and default location for project homes
-               BCI_HOME="$HOME/.bci"
-               mkdir -p "$BCI_HOME"
-       BCI scripts will install to $BCI_HOME/bin
-       which should be added to your $PATH variable
+    config option required is $BCI_HOME
+    this is a place place for bci to store its config options, and default location for project homes
+        BCI_HOME="$HOME/.bci"
+        mkdir -p "$BCI_HOME"
+    BCI scripts will install to $BCI_HOME/bin
+    which should be added to your $PATH variable
 
 
 bci configuration:
-       defaults that bci will use for all projects will be stored in $BCI_HOME/config
-       these can be overridden on a per-project basis by creating a project config file at $BCI_HOME/projects/config
+    defaults that bci will use for all projects will be stored in $BCI_HOME/config
+    these can be overridden on a per-project basis by creating a project config file at $BCI_HOME/projects/config
 
-       config options include:
-               number of builds to keep in history
-       #code note:
-               config file syntax is like: CONFIG_OPTION="VALUE", which can be sourced from bash directly:
-               source $BCI_HOME/config
-               source_if_exists $BCI_HOME/PROJECT/config
+    config options include:
+        number of builds to keep in history
+    #code note:
+        config file syntax is like: CONFIG_OPTION="VALUE", which can be sourced from bash directly:
+        source $BCI_HOME/config
+        source_if_exists $BCI_HOME/PROJECT/config
 
 
 project creation:
-       the only thing BCI requires to create a new project is a location to git clone from
-       additionally, users may specify a project name
-       if no name is given, bci will use the name of the git repository
-       the project stuff will be stored at $BCI_HOME/projects/<project_name>
-       each project requires the user to specify a build command, stored in $BCI_HOME/projects/<project_name>/config
-       for example:
-               build_command="rake release"
+    the only thing BCI requires to create a new project is a location to git clone from
+    additionally, users may specify a project name
+    if no name is given, bci will use the name of the git repository
+    the project stuff will be stored at $BCI_HOME/projects/<project_name>
+    each project requires the user to specify a build command, stored in $BCI_HOME/projects/<project_name>/config
+    for example:
+        build_command="rake release"
 
 
 project organization:
-       $PROJ_HOME will contain three items:
-               $PROJ_HOME/config: (file)
-                       this is where all configuration options for bci_proj will live for this specific project
-               $PROJ_HOME/repo: (directory)
-                       this is where the project itself is checked out. when the project is first created,
-                       specify a remote location to git clone from
-                       run git clone <remote> $PROJ_HOME/repo
-               $PROJ_HOME/data: (directory)
-                       this is where bci will store data relate to previous builds of the project
-                       this includes error logs, build information, test outputs, etc.
+    $PROJ_HOME will contain three items:
+        $PROJ_HOME/config: (file)
+            this is where all configuration options for bci_proj will live for this specific project
+        $PROJ_HOME/repo: (directory)
+            this is where the project itself is checked out. when the project is first created,
+            specify a remote location to git clone from
+            run git clone <remote> $PROJ_HOME/repo
+        $PROJ_HOME/data: (directory)
+            this is where bci will store data relate to previous builds of the project
+            this includes error logs, build information, test outputs, etc.