package argvpb import "fmt" // This file defines the set of conventional exit codes for command-line applications, // These are the standard and common GNU/Linux and BSD `sysexits.h` best practices type ExitCode int const ( ExitSuccess ExitCode = 0 // the program completed its task without errors. ExitFailure ExitCode = 1 // generic, catch-all code for "something went wrong." ExitUsage ExitCode = 64 // EX_USAGE: user provided invalid command-line arguments or flags. ExitDataErr ExitCode = 65 // EX_DATAERR: input data was incorrect or malformed. ExitNoInput ExitCode = 66 // EX_NOINPUT: an input file was not found or could not be read. ExitNoUser ExitCode = 67 // EX_NOUSER: a specified user did not exist. ExitNoHost ExitCode = 68 // EX_NOHOST: a specified host did not exist. ExitUnavailable ExitCode = 69 // EX_UNAVAILABLE: a required service is unavailable. ExitSoftware ExitCode = 70 // EX_SOFTWARE: internal software error. bugs ("this should never happen") ExitOSErr ExitCode = 71 // EX_OSERR: an operating system error, such as a failed system call. ExitOSFile ExitCode = 72 // EX_OSFILE: a critical OS file is missing or corrupt. (e.g., /etc/passwd) ExitCantCreate ExitCode = 73 // EX_CANTCREATE: a user-specified output file could not be created. ExitIOErr ExitCode = 74 // EX_IOERR: an error occurred during an I/O operation. ExitTempFail ExitCode = 75 // EX_TEMPFAIL: temporary failure. The user is invited to retry. ExitProtocol ExitCode = 76 // EX_PROTOCOL: protocol error during network communication. ExitNoPerm ExitCode = 77 // EX_NOPERM: the user does not have sufficient filesystem permissions. ExitConfig ExitCode = 78 // EX_CONFIG: something is wrong in a configuration file. Exit126 ExitCode = 126 // Reserved for shell (command not executable) Exit127 ExitCode = 127 // Reserved for shell (command not found) Exit128 ExitCode = 128 // Reserved for shell (termination by a signal) ExitPB ExitCode = 252525 // NEW FOR ARGV: return a protobuf on exit. todo: need someone to make an RFC for this Exit109 ExitCode = 109 // for testing argv. 109 = 252525 % 256 ) // todo: finish this struct func (x ExitCode) String() string { switch x { case ExitSuccess: return "ExitSuccess" case ExitFailure: return "ExitFailure" case ExitUsage: return "invalid command-line arguments or flags." case ExitDataErr: return "the input data was incorrect or malformed." case ExitNoInput: return "the input file not found, could not be read" case ExitPB: return "In the year 252525, the backwards time-machine still won't have arrived" } return fmt.Sprintf("%d", x) }