Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow intermixing of options and arguments #13

Closed
pklapperich opened this issue Jan 13, 2022 · 0 comments
Closed

Allow intermixing of options and arguments #13

pklapperich opened this issue Jan 13, 2022 · 0 comments

Comments

@pklapperich
Copy link
Contributor

One of the things that's always annoyed me with woof is that it requires all of the options before the arguments.

Example:

$ woof /tmp/Screenshot_2022-01-13_11-12-40.png 
cannot bind to IP address '' port 8080
$ woof /tmp/Screenshot_2022-01-13_11-12-40.png -p 8000

    Usage: woof [-i <ip_addr>] [-p <port>] [-c <count>] <file>
           woof [-i <ip_addr>] [-p <port>] [-c <count>] [-z|-j|-Z|-u] <dir>
           woof [-i <ip_addr>] [-p <port>] [-c <count>] -s
           woof [-i <ip_addr>] [-p <port>] [-c <count>] -U

           woof <url> ... [Snip]

But this is easily fixed by just calling gnu_getopt() instead of getopt()

$ git diff
diff --git a/woof b/woof
index 74784af..414deca 100755
--- a/woof
+++ b/woof
@@ -483,7 +483,7 @@ def main ():
    defaultmaxdown = maxdown
 
    try:
-      options, filenames = getopt.getopt (sys.argv[1:], "hUszjZui:c:p:")
+      options, filenames = getopt.gnu_getopt (sys.argv[1:], "hUszjZui:c:p:")
    except getopt.GetoptError as desc:
       usage (defaultport, defaultmaxdown, desc)

$ ./woof /tmp/Screenshot_2022-01-13_11-12-40.png 
cannot bind to IP address '' port 8080
$ ./woof /tmp/Screenshot_2022-01-13_11-12-40.png -p 8000
Now serving on http://10.0.1.104:8000/Screenshot_2022-01-13_11-12-40.png
simon-budig added a commit that referenced this issue Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant