]> Sergey Matveev's repositories - nnn.git/commitdiff
Update patool wrapper
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 19 May 2019 16:14:58 +0000 (21:44 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Wed, 22 May 2019 03:18:44 +0000 (08:48 +0530)
scripts/natool/natool
src/nnn.c

index 168a22d62d3dba30085d319a96b34f703336c151..0b00066c4baa8ee815387fd35e6474bbeaf0b016 100755 (executable)
@@ -3,16 +3,16 @@
 # #############################################################################
 # natool: a wrapper script to patool to list, extract and create archives
 #
-# usage: natool [-l] [-x] [archive] [file/dir]
+# usage: natool [-a] [-l] [-x] [archive] [file/dir]
 #
 # Examples:
+# - create archive : natool -a archive.7z archive_dir
 # - list archive   : natool -l archive.7z
 # - extract archive: natool -x archive.7z
-# - create archive : natool archive.7z archive_dir
 #
 # Brief:
 # natool is written to integrate patool (instead of the default atool) with nnn
-# Two copies of this file should be dropped somewhere in $PATH - atool, apack
+# A copies of this file should be dropped somewhere in $PATH as atool
 #
 # Author: Arun Prakash Jana
 # Email: engineerarun@gmail.com
@@ -24,17 +24,20 @@ import sys
 from subprocess import Popen, PIPE, DEVNULL
 
 if len(sys.argv) < 3:
-    print('usage: natool [-l] [-x] [archive] [file/dir]')
+    print('usage: natool [-a] [-l] [-x] [archive] [file/dir]')
     sys.exit(0)
 
-if sys.argv[1] == '-x':
-    cmd = ['patool', '--non-interactive', 'extract']
+if sys.argv[1] == '-a':
+    cmd = ['patool', '--non-interactive', 'create', sys.argv[2]]
+    cmd.extend(sys.argv[3:])
 elif sys.argv[1] == '-l':
     cmd = ['patool', '--non-interactive', 'list']
+    cmd.extend(sys.argv[2:])
+elif sys.argv[1] == '-x':
+    cmd = ['patool', '--non-interactive', 'extract']
+    cmd.extend(sys.argv[2:])
 else:
-    cmd = ['patool', '--non-interactive', 'create', sys.argv[1]]
-
-cmd.extend(sys.argv[2:])
+    sys.exit(0)
 
 pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
 out, err = pipe.communicate()
index 38dc3b1cc2ec107571b22124361c41c9b25cb522..6236c5311d128fa518c61cf3c1de2b15afe9c3bb 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3896,7 +3896,7 @@ nochange:
                                char cmd[] = "bsdtar -cf";
 
                                if (getutil(utils[ATOOL]))
-                                       xstrlcpy(cmd, "atool -qa", 10);
+                                       xstrlcpy(cmd, "atool -a", 10);
                                else if (!getutil(utils[BSDTAR])) {
                                        printwait(messages[UTIL_MISSING], &presel);
                                        goto nochange;