All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: btrfs-debugfs: Display usage hint with no arguments
@ 2017-01-03 11:58 Lakshmipathi.G
  2017-01-03 14:46 ` David Sterba
       [not found] ` <ae61834f-3157-dbef-5566-ac102d43cbc4@cn.fujitsu.com>
  0 siblings, 2 replies; 6+ messages in thread
From: Lakshmipathi.G @ 2017-01-03 11:58 UTC (permalink / raw)
  To: linux-btrfs

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

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:
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs-progs: btrfs-debugfs: Display usage hint with no arguments
  2017-01-03 11:58 [PATCH] btrfs-progs: btrfs-debugfs: Display usage hint with no arguments Lakshmipathi.G
@ 2017-01-03 14:46 ` David Sterba
  2017-01-03 15:28   ` Lakshmipathi.G
       [not found] ` <ae61834f-3157-dbef-5566-ac102d43cbc4@cn.fujitsu.com>
  1 sibling, 1 reply; 6+ messages in thread
From: David Sterba @ 2017-01-03 14:46 UTC (permalink / raw)
  To: Lakshmipathi.G; +Cc: linux-btrfs

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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs-progs: btrfs-debugfs: Display usage hint with no arguments
  2017-01-03 14:46 ` David Sterba
@ 2017-01-03 15:28   ` Lakshmipathi.G
  2017-01-03 16:06     ` David Sterba
  0 siblings, 1 reply; 6+ messages in thread
From: Lakshmipathi.G @ 2017-01-03 15:28 UTC (permalink / raw)
  To: dsterba, Lakshmipathi.G, linux-btrfs

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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs-progs: btrfs-debugfs: Display usage hint with no arguments
  2017-01-03 15:28   ` Lakshmipathi.G
@ 2017-01-03 16:06     ` David Sterba
  0 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2017-01-03 16:06 UTC (permalink / raw)
  To: Lakshmipathi.G; +Cc: dsterba, linux-btrfs

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs-progs: btrfs-debugfs: Display usage hint with no arguments
       [not found] ` <ae61834f-3157-dbef-5566-ac102d43cbc4@cn.fujitsu.com>
@ 2017-01-04 14:13   ` Lakshmipathi.G
  0 siblings, 0 replies; 6+ messages in thread
From: Lakshmipathi.G @ 2017-01-04 14:13 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] btrfs-progs: btrfs-debugfs: Display usage hint with no arguments
@ 2017-01-03 10:50 Lakshmipathi.G
  0 siblings, 0 replies; 6+ messages in thread
From: Lakshmipathi.G @ 2017-01-03 10:50 UTC (permalink / raw)
  To: linux-btrfs

---
 btrfs-debugfs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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:
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-04 14:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-03 11:58 [PATCH] btrfs-progs: btrfs-debugfs: Display usage hint with no arguments Lakshmipathi.G
2017-01-03 14:46 ` David Sterba
2017-01-03 15:28   ` Lakshmipathi.G
2017-01-03 16:06     ` David Sterba
     [not found] ` <ae61834f-3157-dbef-5566-ac102d43cbc4@cn.fujitsu.com>
2017-01-04 14:13   ` Lakshmipathi.G
  -- strict thread matches above, loose matches on Subject: below --
2017-01-03 10:50 Lakshmipathi.G

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.