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

Tracking Issue: Documenting Exit Codes #39

Closed
yoshuawuyts opened this issue Jun 7, 2018 · 6 comments
Closed

Tracking Issue: Documenting Exit Codes #39

yoshuawuyts opened this issue Jun 7, 2018 · 6 comments
Assignees
Milestone

Comments

@yoshuawuyts
Copy link
Collaborator

yoshuawuyts commented Jun 7, 2018

Being able to document exit codes would be a useful for many programs, especially when reimplementing existing programs where exit codes can have special meanings.

This thread serves to gather resources about discussions happening around this topic, with the goal that eventually we'll be in a position where it's possible to document all exit codes from our programs.

Related Issues

Links

@killercup
Copy link
Collaborator

Also see "Error handling in CLI apps" (#12), and "Support development of well-behaved CLI apps" (#21), where exit codes came up before

@XAMPPRocky
Copy link

I wonder if as part of providing easy documentation on exit codes if there's a possibility for a standard set of error codes like HTTP. I think specifically having a way categorise common situations such as argument errors, file system errors, and internal errors. This could be used in a abstraction over StatusCode to be extended with third party libraries such as failure and clap.

Example error codes.

  • 400: Incorrect arguments
    • When required arguments are missing or different arguments in conflict are used. (Could be handled directly in command line parsers like clap).
  • 403: Permissions error
    • Program encounter permissions errors when using the file system.
  • 404: File/Directory not found
    • When a path argument provided is not found in the file system.
  • 415: Unsupported File Type
    • The path argument provided contains a file format the program can't handle.

@epage
Copy link
Contributor

epage commented Jun 19, 2018

Didn't realize that sysexits.h hasn't been referenced yet in this issue. See exitcodes

@uazu
Copy link

uazu commented Jun 20, 2018

You only get a byte for exit codes (portably), so numbers 400+ are out. 8 bits isn't a lot of space to pack in much information. I think 0 and 1 take care of most things, and enables the tool user to use if, &&, || etc in their shell. It's only worth passing through other numbers if it makes sense for how that tool is going to be used, e.g. if you expect the user to write shell-scripts that switch behaviour based on different types of failure. Certainly use sysexits.h if that covers your situation, but that is not a fixed rule. User convenience and "least surprise" probably count more.

@Dylan-DPC-zz
Copy link

This might be helpful: http://man7.org/linux/man-pages/man3/errno.3.html

@killercup killercup modified the milestone: Preview 2 Jul 17, 2018
@killercup
Copy link
Collaborator

I'll assign this to me to find a place to put these docs but would eventually like to work with @yoshuawuyts to produce said docs :)

@killercup killercup self-assigned this Jul 24, 2018
@epage epage mentioned this issue Jul 24, 2018
@tvannahl tvannahl mentioned this issue Jul 27, 2018
2 tasks
killercup added a commit to killercup/cli-wg that referenced this issue Aug 1, 2018
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

6 participants