]> Sergey Matveev's repositories - nnn.git/commitdiff
Add program help
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 14 Apr 2017 18:44:25 +0000 (00:14 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 14 Apr 2017 19:24:38 +0000 (00:54 +0530)
README.md
nnn.1
nnn.c

index b62af9091a4434f8ace059c43243e334aeb04419..f73e0ff93edd9c3b9602fe4edc8b9f865fc81e7d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -27,10 +27,11 @@ Noice is Not Noice, a noicer fork...
 - [Installation](#installation)
 - [Quickstart](#quickstart)
 - [Usage](#usage)
-- [Keyboard shortcuts](#keyboard-shortcuts)
-- [Filters](#filters)
-- [File type abbreviations](#file-type-abbreviations)
-- [Help](#help)
+  - [Cmdline options](#cmdline-options)
+  - [Keyboard shortcuts](#keyboard-shortcuts)
+  - [Filters](#filters)
+  - [File type abbreviations](#file-type-abbreviations)
+  - [Help](#help)
 - [Copy current file path to clipboard](#copy-current-file-path-to-clipboard)
 - [Change file associations](#change-file-associations)
 
@@ -168,16 +169,24 @@ Add the following to your shell's rc file for the best experience:
 
 ### 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.
 
-### Keyboard shortcuts
+#### Keyboard shortcuts
 
 | Key | Function |
 | --- | --- |
@@ -209,7 +218,7 @@ Start nnn (default dir: current directory):
 | `?` | Toggle help screen |
 | `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.
 
@@ -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.
 
-### File type abbreviations
+#### File type abbreviations
 
 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 |
 | `c` | Character Device |
 
-### Help
+#### Help
 
     $ man nnn
 To lookup keyboard shortcuts at runtime, press `?`.
diff --git a/nnn.1 b/nnn.1
index 23352db653fe69e3d862651d3cdbac088b602863..7fa55bca3e5adac97d47fe4102ce2bc59fbf9c73 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -3,18 +3,21 @@
 .Os
 .Sh NAME
 .Nm nnn
-.Nd free, fast, friendly file browser
+.Nd the missing terminal file browser for X
 .Sh SYNOPSIS
 .Nm nnn
 .Op Ar -d
-.Op Ar dir
+.Op Ar -S
+.Op Ar -v
+.Op Ar -h
+.Op Ar PATH
 .Sh DESCRIPTION
 .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.
 .Pp
 .Nm
 defaults to the current directory if
-.Ar dir
+.Ar PATH
 is not specified.
 .Pp
 .Nm
@@ -92,6 +95,9 @@ supports the following options:
 .Pp
 .Fl v
         show version and exit
+.Pp
+.Fl h
+        show program help and exit
 .Sh CONFIGURATION
 .Nm
 is configured by modifying
diff --git a/nnn.c b/nnn.c
index b8474bd291f9b7647275e8ab5883740a05064e7e..e79259191c9cae6d62e911ea5bdaf17b9f968025 100644 (file)
--- a/nnn.c
+++ b/nnn.c
@@ -1585,8 +1585,20 @@ nochange:
 static void
 usage(void)
 {
-       fprintf(stderr, "usage: nnn [-d] [-S] [-v] [dir]\n");
-       exit(1);
+       fprintf(stdout, "usage: nnn [-d] [-S] [-v] [h] [PATH]\n\n\
+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
@@ -1605,7 +1617,7 @@ main(int argc, char *argv[])
        if (argc > 3)
                usage();
 
-       while ((opt = getopt(argc, argv, "dSv")) != -1) {
+       while ((opt = getopt(argc, argv, "dSvh")) != -1) {
                switch (opt) {
                case 'S':
                        bsizeorder = 1;
@@ -1615,8 +1627,9 @@ main(int argc, char *argv[])
                        printptr = &printent_long;
                        break;
                case 'v':
-                       fprintf(stderr, "%s\n", VERSION);
+                       fprintf(stdout, "%s\n", VERSION);
                        return 0;
+               case 'h':
                default:
                        usage();
                }