p8952 / bocker

Docker implemented in around 100 lines of bash
https://www.p8952.info/
GNU General Public License v3.0
11.28k stars 716 forks source link

Reduce lines required for documentation #1

Closed SkUrRiEr closed 9 years ago

SkUrRiEr commented 9 years ago

Hey,

GregKH posted this on Google+ and I couldn't help noticing that you could save 6 lines by doing the command documentation in a much more line-efficient manner.

This:

  1. Moves the documentation into the case() code as specially formatted comments.
  2. Severely reduces the readability of the HELP() function by introducing a nasty sed call, saving 5 lines.
  3. Documents the "commit" and "help" commands (Sorry if the commit documentation is crap, I know almost nothing about containers)
  4. Saves another line by moving the exit 0 call out of the HELP() function
  5. Uses $0 instead of "./bocker" by making the nasty sed call nastier

I'm not overly fussed if you pull or not, but this might give you just enough more lines to implement that next big feature you're thinking about.

Thanks,

Julian Calaby

p8952 commented 9 years ago

Thanks for the contribution, looks like a good way of implementing the help function.

But it seems to break under certain versions of sed:

$ sed --version
GNU sed version 4.2.1

$ ./bocker help
Create an image:
    ./bocker init <image_directory>

List images:
    ./bocker images

Create a container:
    ./bocker run <image_id> <command>

List containers:
    ./bocker ps

View logs from a container:
    ./bocker logs <container_id>

Commit a container to the image:
    ./bocker commit <container_id> <image_id>

Delete an image or container:
    ./bocker rm <image_id or container_id>

Display this message:
    ./bocker help
$ sed --version
sed (GNU sed) 4.2.2

$ ./bocker help
sed: -e expression #1, char 27: unknown option to `s'

Any ideas?

SkUrRiEr commented 9 years ago

Argh. I'll try to figure this one out. It might be some crazy quoting issue.

SkUrRiEr commented 9 years ago

Even weirder: My sed is 4.2.2!!!

SkUrRiEr commented 9 years ago

Ok, I've come up with a "hack" that should fix this, unless somehow you've got exclamation marks in your path (which is going to cause you even more problems, but hey) so I'll close this and submit a new request with the new commits.

SkUrRiEr commented 9 years ago

Or github could do that for me by automatically updating this pull request. I had no idea it'd do that, but what the heck.

p8952 commented 9 years ago

Merged! Thanks again :smile: