Make your own domain specific shell (DSS) with
av-shell, the power of a customized cli environment for your project cannot be understated.
This is a really handy tool to organize your scripts and repetitive tasks into one place. When you run 'av', it looks at $PWD and the recursively upward for a '.av' directory. So, in a way, this operates like git and other awesome cli tools but you can insert new commands at your leasure.
- Every script should handle a '-h' argument and output a single line of documentation. This makes the 'help' look nice
- Don't overwrite the builtins
You will need the latest golang. Not using npm anymore. Using oh-my-zsh style of putting it in your home directory under a dot-folder.
git clone https://github.com/sio2boss/av-shell ~/.av && bash ~/.av/install
Using av with your project
In your project folder run this and answer the wizard question(s):
Your project now has a domain specific shell, just run for interactive:
Looks like this:
Or for non-interactive, where help can be replaced with any command:
You will notice there are some docker things in there...make sure you have setup docker like in the Docker section below.
Try creating a new command from the builtin template with:
av new my_new_command
A default editor will be opened if your $EDITOR variable isn't set. Run the following to edit your scripts after they are created:
This is a plugin for av-shell that integrates docker with your project.
Need docker or Docker.app
Setup the folder you want to have your docker containers located in, e.x. "containers":
av> setpv containerdir containers
Now setup the repo you will push containers to. Could be dockerhub:
av> setpv repo somehostname:port
Under the "containers" directory, create a folder for each container you want to use where you can put your Dockerfile and a Runfile (more about the latter later). I've include an example directory in this repo for you to copy and use as you like. Av-docker adds the 'choose' command:
av> choose ? Which do you want? nginx Using nginx as container for docker commands av [nginx]>
You will notice how your av-shell prompt has changed to include the selected container.
Now you can use normal docker commands but without typing docker and the container name each time.
We are going to use a special av feature to show one way domain specific shells kick ass...
Lets build the nginx container
For a custom container, you will certainly want to setup the Runfile with docker arguments like this:
-d -p 80:80 -v $(pwd)/../../log:/var/log/nginx
Now start the container with the 'run' command:
The command should output some huge hash value. The first 12 chars can always be found with a ps
ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e1526432ae2f nginx /usr/local/bin/run 31 seconds ago Up 31 seconds 0.0.0.0:80->80/tcp stupefied_morse
But lets stop it with that 'holdhash' feature
And start it back up again
Handy right? Well what if we what to shell into that container? av will help you here (need docker 1.3+)
Lets shut it down
And perminantly remove it
How many times did you not have to type docker? Make your life easy with av-docker!