From a3ab7c916a7a1d53052f8e794ba4aa2c06d3c918 Mon Sep 17 00:00:00 2001 From: "Mike D. Lowis" Date: Sun, 4 Mar 2012 11:46:17 -0500 Subject: [PATCH] Added bci based on usage.txt --- bci | 71 +++++++++++++++++++++++++++ usage.txt | 142 +++++++++++++++++++++++++++--------------------------- 2 files changed, 142 insertions(+), 71 deletions(-) create mode 100644 bci diff --git a/bci b/bci new file mode 100644 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 Adds a project to bci + del Deletes a project from bci + ls Lists all projects + update Force a pull on the specified project + build 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 diff --git a/usage.txt b/usage.txt index aa159af..3f7bac2 100644 --- 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 - create a bci project named that will live in $BCI_HOME/projects/ - $ PROJ_HOME="$BCI_HOME/projects/" - $ mkdir -p "$PROJ_HOME" - $ mkdir -p "$PROJ_HOME/data" - $ git clone $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 - delete the project named - $ #todo: add a prompt (eventually using QBALL_YES_NO_PROMPT, or just a simple "Y/N") - $ rm -rf "$BCI_HOME/projects/" - bci ls (TODO: [expression]) - list all projects (TODO: that match an optional expression) - $ ls "$BCI_HOME/projects" + bci add + create a bci project named that will live in $BCI_HOME/projects/ + $ PROJ_HOME="$BCI_HOME/projects/" + $ mkdir -p "$PROJ_HOME" + $ mkdir -p "$PROJ_HOME/data" + $ git clone $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 + delete the project named + $ #todo: add a prompt (eventually using QBALL_YES_NO_PROMPT, or just a simple "Y/N") + $ rm -rf "$BCI_HOME/projects/" + 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 - force a pull of the specified project - TODO: create an alias for this command, bci pull - $ pushd "$BCI_HOME/projects//repo" - $ git pull - $ popd - bci build - force a bulid of the specified project - note: this does not implicity update - $ pushd "$BCI_HOME/projects//repo" - $ source "$BCI_HOME/projects//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 - set config option for a bci project named - TODO: introduce mechanism to make 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 + force a pull of the specified project + TODO: create an alias for this command, bci pull + $ pushd "$BCI_HOME/projects//repo" + $ git pull + $ popd + bci build + force a bulid of the specified project + note: this does not implicity update + $ pushd "$BCI_HOME/projects//repo" + $ source "$BCI_HOME/projects//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 + set config option for a bci project named + TODO: introduce mechanism to make 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/ - each project requires the user to specify a build command, stored in $BCI_HOME/projects//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/ + each project requires the user to specify a build command, stored in $BCI_HOME/projects//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 $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 $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. -- 2.54.0