Skip to content

Attempts to add command line argument parsing with getopt_long. - #25

Open
Yetoo1 wants to merge 1 commit into
klaxa:masterfrom
Yetoo1:arguments
Open

Attempts to add command line argument parsing with getopt_long.#25
Yetoo1 wants to merge 1 commit into
klaxa:masterfrom
Yetoo1:arguments

Conversation

@Yetoo1

@Yetoo1 Yetoo1 commented Aug 20, 2019

Copy link
Copy Markdown

This commit attempts to add command line options -a -h -p -r -u and
adds help documentation. This was using getopt_long. The url can be
customized with -r, -a, and -p (address, protocol, and port respectively)
with -u overriding the aformentioned options if submitted alongside and
allowing to specify a url string with appropriate components concatenated
in a single string. The following is the help text and gives more description:
usage: server [-ahpru] [file]
The default generated url is http://0:8080
A url can be customized by providing the address (-a), port (-p), or protocol (-r). A url can be entered in full with the -u option.
-a, --address Specify an address to use in url (default 0)
-h, --help Print this help message
-p, --port Specify a port to use in url (default 8080)
-r, --protocol Specify a protocol to use in url (default http)
-u, --url Specify a url with the following format. (protocol://address:port).
If other options are used with -u, -u will override the other options.

Issues:

  1. The protocol on a generated or supplied url gives a Failed to open server:
    Protocol not found and it looks like there is healthy output, but testing
    download looks like the request isn't being registered. I've found that if a
    literal string is substituted for the url string, this issue doesn't happen,
    but if the string is generated or delivered from a char* or const char* the
    error occurrs.
  2. Input from redirection and/or pipe may not be correctly handled (it wasn't
    correctly handled in the latest commit in master).

This commit attempts to add command line options -a -h -p -r -u and
adds help documentation. This was using getopt_long. The url can be
customized with -r, -a, and -p (address, protocol, and port respectively)
with -u overriding the aformentioned options if submitted alongside and
allowing to specify a url string with appropriate components concatenated
in a single string. The following is the help text and gives more description:
usage: server [-ahpru] [file]
The default generated url is http://0:8080
A url can be customized by providing the address (-a), port (-p), or protocol (-r). A url can be entered in full with the -u option.
-a, --address    Specify an address to use in url (default 0)
-h, --help       Print this help message
-p, --port       Specify a port to use in url (default 8080)
-r, --protocol   Specify a protocol to use in url (default http)
-u, --url        Specify a url with the following format. (protocol://address:port).
                 If other options are used with -u, -u will override the other options.

Issues:
1. The protocol on a generated or supplied url gives a Failed to open server:
Protocol not found and it looks like there is healthy output, but testing
download looks like the request isn't being registered. I've found that if a
literal string is substituted for the url string, this issue doesn't happen,
but if the string is generated or delivered from a char* or const char* the
error occurrs.
2. Input from redirection and/or pipe may not be correctly handled (it wasn't
correctly handled in the latest commit in master).
@Yetoo1

Yetoo1 commented Aug 20, 2019

Copy link
Copy Markdown
Author

Any help and/or suggestions would be appreciated to resolve both issues with this commit.

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

Successfully merging this pull request may close these issues.

1 participant