BSD Sysexits for Zig

feat: more explicit values

matrixfurry.com 4699dacf 1c0e3c42

verified
+15 -15
+15 -15
src/root.zig
··· 20 21 /// The command was used incorrectly (e.g. wrong number of arguments, 22 /// bad flag, bad syntax in a parameter, etc). 23 - pub const usage: u8 = metadata.base; 24 25 /// The input data was incorrect in some way. This should only be used 26 /// for user's data and not system files (which should use `os_file` 27 /// instead). 28 - pub const data_err: u8 = metadata.base + 1; 29 30 /// An input file (not a system file, use `os_file` for that) did not 31 /// exist or was not readable. 32 - pub const no_input: u8 = metadata.base + 2; 33 34 /// The user specified did not exist. 35 - pub const no_user: u8 = metadata.base + 3; 36 37 /// The host specified did not exist. This is used in network requests. 38 - pub const no_host: u8 = metadata.base + 4; 39 40 /// A service is unavailable. This can occur if a support program or 41 /// file does not exist. This can also be used as a catchall message 42 /// when something you wanted to do doesn't work, but you don't know 43 /// why. 44 - pub const unavailable: u8 = metadata.base + 5; 45 46 /// An internal software error has been detected. This should be limited 47 /// to non-operating system related errors if possible. 48 - pub const software: u8 = metadata.base + 6; 49 50 /// An operating system error has been detected. This is intended to be 51 /// used for such things as "cannot fork", "cannot create pipe", etc. 52 - pub const os_err: u8 = metadata.base + 7; 53 54 /// Some system file (e.g. /etc/passwd, /var/run/utmp, etc.) does not 55 /// exist, cannot be opened, or has some sort of error (e.g. syntax 56 /// error). 57 - pub const os_file: u8 = metadata.base + 8; 58 59 /// A user-specified output file cannot be created. 60 - pub const cant_create: u8 = metadata.base + 9; 61 62 /// An error occurred while doing I/O on some file. 63 - pub const io_err: u8 = metadata.base + 10; 64 65 /// Temporary failure, indicating something that is not really an error. 66 /// For example, if a connection could not be created and should be 67 /// reattempted later. 68 - pub const temp_fail: u8 = metadata.base + 11; 69 70 /// The remote system returned something illegal during a protocol 71 /// exchange. 72 - pub const protocol: u8 = metadata.base + 12; 73 74 /// You did not have sufficient permission to perform the operation. 75 /// This is not intended for filesystem problems, which should use 76 /// `no_input` or `cant_create`. but rather for higher level 77 /// permissions. 78 - pub const no_permission: u8 = metadata.base + 13; 79 80 /// Something was found in an unconfigured or misconfigured state. 81 - pub const config: u8 = metadata.base + 14; 82 83 test "metadata matches BSD sysexits" { 84 try testing.expectEqual(metadata.base, 64);
··· 20 21 /// The command was used incorrectly (e.g. wrong number of arguments, 22 /// bad flag, bad syntax in a parameter, etc). 23 + pub const usage: u8 = 64; 24 25 /// The input data was incorrect in some way. This should only be used 26 /// for user's data and not system files (which should use `os_file` 27 /// instead). 28 + pub const data_err: u8 = 65; 29 30 /// An input file (not a system file, use `os_file` for that) did not 31 /// exist or was not readable. 32 + pub const no_input: u8 = 66; 33 34 /// The user specified did not exist. 35 + pub const no_user: u8 = 67; 36 37 /// The host specified did not exist. This is used in network requests. 38 + pub const no_host: u8 = 68; 39 40 /// A service is unavailable. This can occur if a support program or 41 /// file does not exist. This can also be used as a catchall message 42 /// when something you wanted to do doesn't work, but you don't know 43 /// why. 44 + pub const unavailable: u8 = 69; 45 46 /// An internal software error has been detected. This should be limited 47 /// to non-operating system related errors if possible. 48 + pub const software: u8 = 70; 49 50 /// An operating system error has been detected. This is intended to be 51 /// used for such things as "cannot fork", "cannot create pipe", etc. 52 + pub const os_err: u8 = 71; 53 54 /// Some system file (e.g. /etc/passwd, /var/run/utmp, etc.) does not 55 /// exist, cannot be opened, or has some sort of error (e.g. syntax 56 /// error). 57 + pub const os_file: u8 = 72; 58 59 /// A user-specified output file cannot be created. 60 + pub const cant_create: u8 = 73; 61 62 /// An error occurred while doing I/O on some file. 63 + pub const io_err: u8 = 74; 64 65 /// Temporary failure, indicating something that is not really an error. 66 /// For example, if a connection could not be created and should be 67 /// reattempted later. 68 + pub const temp_fail: u8 = 75; 69 70 /// The remote system returned something illegal during a protocol 71 /// exchange. 72 + pub const protocol: u8 = 76; 73 74 /// You did not have sufficient permission to perform the operation. 75 /// This is not intended for filesystem problems, which should use 76 /// `no_input` or `cant_create`. but rather for higher level 77 /// permissions. 78 + pub const no_permission: u8 = 77; 79 80 /// Something was found in an unconfigured or misconfigured state. 81 + pub const config: u8 = 78; 82 83 test "metadata matches BSD sysexits" { 84 try testing.expectEqual(metadata.base, 64);