Skip to contentSkip to conversation

btrfs-progs: btrfs-debugfs: Display usage hint with no arguments

PATCH In review Lakshmipathi.G 2 participants 5 messages Jan 3, 2017 – Jan 4, 2017 1 message not in the archive Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: btrfs-debugfs: Display usage hint with no arguments

---
 btrfs-debugfs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
btrfs-debugfs +3 -1
index dfb8853..70419fa 100755
@@ -392,7 +392,9 @@ parser.add_argument('-f', '--file', action='store_const', const=1, help='get fil
 
 args = parser.parse_args()
 
-if args.block_group:
+if not (args.block_group or args.file):
+    print "No arguments passed. Type 'btrfs-debugfs -h' for usage."
+elif args.block_group:
     for i in args.path[0:]:
         print_block_groups(i)
 elif args.file:
Signature · 1 line
2.7.4
#1 lore raw

This is what I see when no arguments pare passed:

$ ./btrfs-debugfs
usage: btrfs-debugfs [-h] [-b] [-f] path [path ...]
btrfs-debugfs: error: too few arguments

And that's exactly the same output as with this patch applied. Am I missing something?

#2 lore raw

Sorry about the misleading subject line. This patch is for missing optional arguments.

Before the patch:

$ ./btrfs-debugfs /mnt/file.txt   # Does nothing and silently fails.

After the patch:

$ ./btrfs-debugfs /mnt/file.txt
No arguments passed. Type 'btrfs-debugfs -h' for usage.

----
Cheers,
Lakshmipathi.G
FOSS Programmer.
www.giis.co.in

Quoted 8 lines · David Sterba

This is what I see when no arguments pare passed:

$ ./btrfs-debugfs
usage: btrfs-debugfs [-h] [-b] [-f] path [path ...]
btrfs-debugfs: error: too few arguments

And that's exactly the same output as with this patch applied. Am I missing something?

#3 lore raw
Quoted 9 lines · Lakshmipathi.G

Sorry about the misleading subject line. This patch is for missing optional arguments.

Before the patch:

$ ./btrfs-debugfs /mnt/file.txt   # Does nothing and silently fails.

After the patch:

$ ./btrfs-debugfs /mnt/file.txt
No arguments passed. Type 'btrfs-debugfs -h' for usage.

That still looks confusing to me, as I'd count /mnt/file.txt as an argument. Even -h lists all the -h/-b/-f as optional arugments.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

I think we can achieve above help string with the help of custom usage function instead of using argparse default usage. I'll check and send a new patch.

----
Cheers,
Lakshmipathi.G
FOSS Programmer.
www.giis.co.in

Quoted 8 lines · Qu Wenruo

What about changing current help string to:

btrfs-debugfs -b|-f path
or
btrfs-debugfs -h

Thanks,
Qu