2014-12-02 20:11:09 (UTC-02:00)
Marcel Rodrigues <marcelgmr@gmail.com>
Documentation improvements. Add --version and --help options. Add man page. Probably needs more polishing. Add command to show man page from inside Rover.
diff --git a/config.h b/config.h index 185a402..07fcaee 100644 --- a/config.h +++ b/config.h @@ -1,7 +1,9 @@ +#define RV_VERSION "0.0.0" + /* CTRL+X: "^X" - * ALT+X: "M-X" - */ + ALT+X: "M-X" */ #define RVK_QUIT "q" +#define RVK_HELP "?" #define RVK_DOWN "j" #define RVK_UP "k" #define RVK_JUMP_DOWN "J" diff --git a/rover.1 b/rover.1 new file mode 100644 index 0000000..1df20b1 --- /dev/null +++ b/rover.1 @@ -0,0 +1,112 @@ +.TH ROVER 1 rover\-0.0.0 +.SH NAME +rover \- file browser for the terminal +.SH SYNOPSIS +.B rover +[\fI\,DIRECTORY \/\fR[\fI\,DIRECTORY \/\fR[\fI\,DIRECTORY \/\fR[...]]]] +.br +.B rover +[\fI\,OPTION\/\fR] +.SH DESCRIPTION +Browse current working directory or the ones specified. +.SH OPTIONS +.TP +\fB\-h\fR, \fB\-\-help\fR +print help message and exit +.TP +\fB\-v\fR, \fB\-\-version\fR +print program version and exit +.SH ENVIRONMENT VARIABLES +.TP +.B HOME +Full path of the home directory. +.TP +.B PATH +Colon\-separated path list for program directories. +.TP +.B SHELL +Name of shell program (e.g. \fI\,/bin/sh\/\fP). +.TP +.B PAGER +Name of pager program (e.g. \fI\,less\/\fP). +.TP +.B EDITOR +Name of editor program (e.g. \fI\,vim\/\fP or \fI\,emacs\/\fP). +.SH EXAMPLES +.TP +Open current working directory on all tabs: +rover +.TP +Open a tab for directory \fI\,foo\/\fP and another for \fI\,bar\/\fP: +rover foo bar +.TP +Open one tab for each directory inside \fI\,/usr/\/\fP: +rover /usr/*/ +.SH COMMANDS +.TP +.B q +Quit rover. +.TP +.B j/k +Move cursor down/up. +.TP +.B J/K +Move cursor down/up 10 lines. +.TP +.B l +Enter selected directory. +.TP +.B h +Go to parent directory. +.TP +.B H +Go to \fB$HOME\fR directory. +.TP +.B <RETURN> +Open \fB$SHELL\fR on the current directory. +.TP +.B <SPACE> +Open \fB$PAGER\fR with the selected file. +.TP +.B e +Open \fB$EDITOR\fR with the selected file. +.TP +.B / +Start incremental search (\fB<RETURN>\fR to finish). +.TP +.B f/d/s +Toggle file/directory/hidden listing. +.TP +.B n/N +Create new file/directory. +.TP +.B r +Rename selected file or directory. +.TP +.B m +Toggle mark on the selected entry. +.TP +.B M +Toggle mark on all visible entries. +.TP +.B a +Mark all visible entries. +.TP +.B X/C/V +Delete/copy/move all marked entries. +.TP +.B 0-9 +Change tab. +.SH NOTES +.PP +\fBImportant\fR: Currently, Rover never asks for confirmation before overwriting +existing files while copying/moving marked entries. Please be careful to not +accidentally lose your data. +.PP +There are always exactly 10 tabs open, numbered from 0 to 9. The tab number 0 +always start at $HOME. If more than nine directories are specified, only the +first nine are used for tabs 1\-9 and the rest is ignored. Tabs for which an +invalid path were assigned will also start at $HOME. Remaining tabs not +specified on the command line start at the current working directory. +.PP +Rover homepage: <https://github.com/lecram/rover>. diff --git a/rover.c b/rover.c index 1b748cc..ae0e144 100644 --- a/rover.c +++ b/rover.c @@ -665,6 +665,24 @@ main(int argc, char *argv[]) char *program, *key; DIR *d; + if (argc == 2) { + if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) { + printf("rover %s\n", RV_VERSION); + return 0; + } else if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { + printf( + "Usage: rover [DIRECTORY [DIRECTORY [DIRECTORY [...]]]]\n" + " or: rover [OPTION]\n" + "Browse current working directory or the ones specified.\n\n" + "Options:\n" + " -h, --help print this help message and exit\n" + " -v, --version print program version and exit\n\n" + "See rover(1) for more information.\n\n" + "Rover homepage: <https://github.com/lecram/rover>.\n" + ); + return 0; + } + } init_term(); rover.nfiles = 0; for (i = 0; i < 10; i++) { @@ -697,6 +715,11 @@ main(int argc, char *argv[]) else if (ch >= '0' && ch <= '9') { rover.tab = ch - '0'; cd(0); + } else if (!strcmp(key, RVK_HELP)) { + ARGS[0] = "man"; + ARGS[1] = "rover"; + ARGS[2] = NULL; + spawn(); } else if (!strcmp(key, RVK_DOWN)) { if (!rover.nfiles) continue; ESEL = (ESEL + 1) % rover.nfiles;