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

Message ID 20170103115813.GA3228@fedori
State New
Headers show

Commit Message

Lakshmipathi.G Jan. 3, 2017, 11:58 a.m. UTC
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
---
 btrfs-debugfs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

David Sterba Jan. 3, 2017, 2:46 p.m. UTC | #1
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?
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lakshmipathi.G Jan. 3, 2017, 3:28 p.m. UTC | #2
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


On Tue, Jan 3, 2017 at 8:16 PM, David Sterba <dsterba@suse.cz> wrote:
> 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?
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba Jan. 3, 2017, 4:06 p.m. UTC | #3
On Tue, Jan 03, 2017 at 08:58:44PM +0530, Lakshmipathi.G wrote:
> 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.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lakshmipathi.G Jan. 4, 2017, 2:13 p.m. UTC | #4
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


On Wed, Jan 4, 2017 at 6:14 AM, Qu Wenruo <quwenruo@cn.fujitsu.com> wrote:
> What about changing current help string to:
>
> btrfs-debugfs -b|-f path
> or
> btrfs-debugfs -h
>
> Thanks,
> Qu
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/btrfs-debugfs b/btrfs-debugfs
index dfb8853..70419fa 100755
--- a/btrfs-debugfs
+++ b/btrfs-debugfs
@@ -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: