Add program help

This commit is contained in:
Arun Prakash Jana 2017-04-15 00:14:25 +05:30
parent cd212b23b9
commit ccb320d627
No known key found for this signature in database
GPG key ID: A75979F35C080412
3 changed files with 48 additions and 20 deletions

View file

@ -27,10 +27,11 @@ Noice is Not Noice, a noicer fork...
- [Installation](#installation) - [Installation](#installation)
- [Quickstart](#quickstart) - [Quickstart](#quickstart)
- [Usage](#usage) - [Usage](#usage)
- [Keyboard shortcuts](#keyboard-shortcuts) - [Cmdline options](#cmdline-options)
- [Filters](#filters) - [Keyboard shortcuts](#keyboard-shortcuts)
- [File type abbreviations](#file-type-abbreviations) - [Filters](#filters)
- [Help](#help) - [File type abbreviations](#file-type-abbreviations)
- [Help](#help)
- [Copy current file path to clipboard](#copy-current-file-path-to-clipboard) - [Copy current file path to clipboard](#copy-current-file-path-to-clipboard)
- [Change file associations](#change-file-associations) - [Change file associations](#change-file-associations)
@ -168,16 +169,24 @@ Add the following to your shell's rc file for the best experience:
### Usage ### Usage
Start nnn (default dir: current directory): #### Cmdline options
$ nnn [-d] [-S] [-v] [dir] usage: nnn [-d] [-S] [-v] [h] [PATH]
The missing terminal file browser for X.
positional arguments:
PATH directory to open [default: current dir]
optional arguments:
-d start in detail view mode
-S start in disk usage analyzer mode
-v show program version and exit
-h show this help and exit
-d: start in detail view mode
-S: start in disk usage analyzer mode
-v: show version and exit
`>` indicates the currently selected entry in nnn. `>` indicates the currently selected entry in nnn.
### Keyboard shortcuts #### Keyboard shortcuts
| Key | Function | | Key | Function |
| --- | --- | | --- | --- |
@ -209,7 +218,7 @@ Start nnn (default dir: current directory):
| `?` | Toggle help screen | | `?` | Toggle help screen |
| `q` | Quit | | `q` | Quit |
### Filters #### Filters
Filters support regexes to display only the matched entries in the current directory view. This effectively allows searching through the directory tree for a particular entry. Filters support regexes to display only the matched entries in the current directory view. This effectively allows searching through the directory tree for a particular entry.
@ -219,7 +228,7 @@ An empty filter expression resets the filter.
If nnn is invoked as root the default filter will also match hidden files. If nnn is invoked as root the default filter will also match hidden files.
### File type abbreviations #### File type abbreviations
The following abbreviations are used in the detail view: The following abbreviations are used in the detail view:
@ -233,7 +242,7 @@ The following abbreviations are used in the detail view:
| `b` | Block Device | | `b` | Block Device |
| `c` | Character Device | | `c` | Character Device |
### Help #### Help
$ man nnn $ man nnn
To lookup keyboard shortcuts at runtime, press `?`. To lookup keyboard shortcuts at runtime, press `?`.

12
nnn.1
View file

@ -3,18 +3,21 @@
.Os .Os
.Sh NAME .Sh NAME
.Nm nnn .Nm nnn
.Nd free, fast, friendly file browser .Nd the missing terminal file browser for X
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm nnn .Nm nnn
.Op Ar -d .Op Ar -d
.Op Ar dir .Op Ar -S
.Op Ar -v
.Op Ar -h
.Op Ar PATH
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
(Noice is Not Noice) is a fork of the noice terminal file browser with improved desktop integration, navigation, disk usage analyzer mode, comprehensive file details and much more. It remains a simple and efficient file browser that stays out of your way. (Noice is Not Noice) is a fork of the noice terminal file browser with improved desktop integration, navigation, disk usage analyzer mode, comprehensive file details and much more. It remains a simple and efficient file browser that stays out of your way.
.Pp .Pp
.Nm .Nm
defaults to the current directory if defaults to the current directory if
.Ar dir .Ar PATH
is not specified. is not specified.
.Pp .Pp
.Nm .Nm
@ -92,6 +95,9 @@ supports the following options:
.Pp .Pp
.Fl v .Fl v
show version and exit show version and exit
.Pp
.Fl h
show program help and exit
.Sh CONFIGURATION .Sh CONFIGURATION
.Nm .Nm
is configured by modifying is configured by modifying

21
nnn.c
View file

@ -1585,8 +1585,20 @@ nochange:
static void static void
usage(void) usage(void)
{ {
fprintf(stderr, "usage: nnn [-d] [-S] [-v] [dir]\n"); fprintf(stdout, "usage: nnn [-d] [-S] [-v] [h] [PATH]\n\n\
exit(1); The missing terminal file browser for X.\n\n\
positional arguments:\n\
PATH directory to open [default: current dir]\n\n\
optional arguments:\n\
-d start in detail view mode\n\
-S start in disk usage analyzer mode\n\
-v show program version and exit\n\
-h show this help and exit\n\n\
Version: %s\n\
License: BSD 2-Clause\n\
Webpage: https://github.com/jarun/nnn\n", VERSION);
exit(0);
} }
int int
@ -1605,7 +1617,7 @@ main(int argc, char *argv[])
if (argc > 3) if (argc > 3)
usage(); usage();
while ((opt = getopt(argc, argv, "dSv")) != -1) { while ((opt = getopt(argc, argv, "dSvh")) != -1) {
switch (opt) { switch (opt) {
case 'S': case 'S':
bsizeorder = 1; bsizeorder = 1;
@ -1615,8 +1627,9 @@ main(int argc, char *argv[])
printptr = &printent_long; printptr = &printent_long;
break; break;
case 'v': case 'v':
fprintf(stderr, "%s\n", VERSION); fprintf(stdout, "%s\n", VERSION);
return 0; return 0;
case 'h':
default: default:
usage(); usage();
} }