|
| 1 | +function __fish_usbguard_complete_first_subcommand |
| 2 | + set -l cmd (commandline -opc) |
| 3 | + if test (count $cmd) -eq 1 |
| 4 | + return 0 |
| 5 | + end |
| 6 | + return 1 |
| 7 | +end |
| 8 | + |
| 9 | +set -l subcommands \ |
| 10 | + "get-parameter\tGet the value of a runtime parameter" \ |
| 11 | + "set-parameter\tSet the value of a runtime parameter" \ |
| 12 | + "list-devices\tList all USB devices recognized by the USBGuard daemon" \ |
| 13 | + "allow-device\tAuthorize a device to interact with the system" \ |
| 14 | + "block-device\tDeauthorize a device" \ |
| 15 | + "reject-device\tDeauthorize and remove a device" \ |
| 16 | + "list-rules\tList the rule set (policy) used by the USBGuard daemon" \ |
| 17 | + "append-rule\tAppend the rule to ther current rule set" \ |
| 18 | + "remove-rule\tRemove a rule identified by the rule id from the rule set" \ |
| 19 | + "generate-policy\tGenerate a rule set (policy) which authorizes currently connected USB devices" \ |
| 20 | + "watch\tWatch the IPC interface events and print them to stdout" \ |
| 21 | + "read-descriptor\tRead a USB descriptor from a file and print it in human-readable format" \ |
| 22 | + "add-user\tCreate an IPC access control file allowing user/group to use the USBGuard IPC bus" \ |
| 23 | + "remove-user\tRemove an IPC access control file associated with the user/group" |
| 24 | + |
| 25 | +complete -c usbguard -x |
| 26 | + |
| 27 | +for part in $subcommands |
| 28 | + set -l cmd (string split -f 1 "\t" "$part") |
| 29 | + |
| 30 | + complete -c usbguard -x -n "__fish_usbguard_complete_first_subcommand" -a "$cmd" -d (string split -f 2 "\t" "$part") |
| 31 | + complete -c usbguard -x -n "__fish_seen_subcommand_from $cmd" -s "h" -l "help" -d "Show help" |
| 32 | +end |
| 33 | + |
| 34 | +for cmd in get-parameter set-parameter |
| 35 | + complete -c usbguard -x -n "__fish_seen_subcommand_from $cmd; and not __fish_seen_subcommand_from InsertedDevicePolicy; and not __fish_seen_subcommand_from ImplicitPolicyTarget" -a "InsertedDevicePolicy ImplicitPolicyTarget" |
| 36 | +end |
| 37 | +complete -c usbguard -x -n "__fish_seen_subcommand_from set-parameter" -s "v" -l "verbose" -d "Print the previous and new attribute value" |
| 38 | +complete -c usbguard -x -n "__fish_seen_subcommand_from set-parameter; and __fish_seen_subcommand_from InsertedDevicePolicy" -a "block" -d "Deauthorize every present device" |
| 39 | +complete -c usbguard -x -n "__fish_seen_subcommand_from set-parameter; and __fish_seen_subcommand_from InsertedDevicePolicy" -a "reject" -d "Remove every present device" |
| 40 | +complete -c usbguard -x -n "__fish_seen_subcommand_from set-parameter; and __fish_seen_subcommand_from InsertedDevicePolicy" -a "apply-policy" -d "Evaluate the ruleset for every present device" |
| 41 | +complete -c usbguard -x -n "__fish_seen_subcommand_from set-parameter; and __fish_seen_subcommand_from ImplicitPolicyTarget" -a "allow" -d "Authorize the device" |
| 42 | +complete -c usbguard -x -n "__fish_seen_subcommand_from set-parameter; and __fish_seen_subcommand_from ImplicitPolicyTarget" -a "block" -d "Block the device" |
| 43 | +complete -c usbguard -x -n "__fish_seen_subcommand_from set-parameter; and __fish_seen_subcommand_from ImplicitPolicyTarget" -a "reject" -d "Remove the device" |
| 44 | + |
| 45 | +complete -c usbguard -x -n "__fish_seen_subcommand_from list-devices" -s "a" -l "allowed" -d "List allowed devices" |
| 46 | +complete -c usbguard -x -n "__fish_seen_subcommand_from list-devices" -s "b" -l "blocked" -d "List blocked devices" |
| 47 | +complete -c usbguard -x -n "__fish_seen_subcommand_from list-devices" -s "t" -l "tree" -d "List devices in a tree format" |
| 48 | + |
| 49 | +for cmd in allow-device block-device reject-device |
| 50 | + complete -c usbguard -x -n "__fish_seen_subcommand_from $cmd" -s "p" -l "permanent" -d "Make the decision permanent" |
| 51 | +end |
| 52 | + |
| 53 | +complete -c usbguard -x -n "__fish_seen_subcommand_from list-rules" -s "d" -l "show-devices" -d "Show all devices which are affected by the specific rule" |
| 54 | +complete -c usbguard -x -n "__fish_seen_subcommand_from list-rules" -s "l" -l "label" -d "Only show rules having a specific label" |
| 55 | + |
| 56 | +complete -c usbguard -x -n "__fish_seen_subcommand_from append-rule" -s "a" -l "after" -d "Append the new rule after a rule with the specified rule id" |
| 57 | +complete -c usbguard -x -n "__fish_seen_subcommand_from append-rule" -s "t" -l "temporary" -d "Make the desicion temporary" |
| 58 | + |
| 59 | +complete -c usbguard -x -n "__fish_seen_subcommand_from generate-policy" -s "p" -l "with-ports" -d "Generate port specific rules for all devices" |
| 60 | +complete -c usbguard -x -n "__fish_seen_subcommand_from generate-policy" -s "P" -l "no-ports-sn" -d "Don't generate port specific rules for devices without an iSerial value" |
| 61 | +complete -c usbguard -x -n "__fish_seen_subcommand_from generate-policy" -s "d" -l "devpath" -d "Only generate a rule for devices at the specified sub path of /sys" |
| 62 | +complete -c usbguard -x -n "__fish_seen_subcommand_from generate-policy" -s "t" -l "target" -d "Generate an explicit \"catch all\" rule with the specified target" |
| 63 | +complete -c usbguard -x -n "__fish_seen_subcommand_from generate-policy" -s "X" -l "no-hashes" -d "Don't generate a hash attribute for each device" |
| 64 | +complete -c usbguard -x -n "__fish_seen_subcommand_from generate-policy" -s "H" -l "hash-only" -d "Generate a hash-only policy" |
| 65 | +complete -c usbguard -x -n "__fish_seen_subcommand_from generate-policy" -s "L" -l "ldif" -d "Generate a ldif policy for LDAP" |
| 66 | +complete -c usbguard -x -n "__fish_seen_subcommand_from generate-policy" -s "b" -l "usbguardbase" -d "Generate a ldif policy for LDAP with specified base" |
| 67 | +complete -c usbguard -x -n "__fish_seen_subcommand_from generate-policy" -s "o" -l "objectclass" -d "Generate a ldif policy for LDAP with specified objectClass" |
| 68 | +complete -c usbguard -x -n "__fish_seen_subcommand_from generate-policy" -s "n" -l "name-prefix" -d "Generate a ldif policy for LDAP with specified name prefix" |
| 69 | + |
| 70 | +complete -c usbguard -x -n "__fish_seen_subcommand_from watch" -s "w" -l "wait" -d "Wait for IPC connection to become available" |
| 71 | +complete -c usbguard -x -n "__fish_seen_subcommand_from watch" -s "o" -l "once" -d "Wait only when starting, if needed" |
| 72 | +complete -c usbguard -F -r -n "__fish_seen_subcommand_from watch" -s "e" -l "exec" -d "Run an executable file located at specified path for every event" |
| 73 | + |
| 74 | +for cmd in add-user remove-user |
| 75 | + complete -c usbguard -x -n "__fish_seen_subcommand_from $cmd" -a "(__fish_complete_users)" |
| 76 | + complete -c usbguard -x -n "__fish_seen_subcommand_from $cmd" -a "(__fish_complete_user_ids)" |
| 77 | + complete -c usbguard -n "__fish_seen_subcommand_from $cmd" -s "u" -l "user" -d "Specified name representing a username or UID (default)" |
| 78 | + |
| 79 | + complete -c usbguard -x -n "__fish_seen_subcommand_from $cmd" -s "g" -l "group" -a "(__fish_complete_groups)" |
| 80 | + complete -c usbguard -x -n "__fish_seen_subcommand_from $cmd" -s "g" -l "group" -a "(__fish_complete_group_ids)" |
| 81 | + complete -c usbguard -x -n "__fish_seen_subcommand_from $cmd" -s "g" -l "group" -d "Specified name representing a group name or GID" |
| 82 | +end |
| 83 | +complete -c usbguard -n "__fish_seen_subcommand_from add-user" -s "p" -l "policy" -d "Policy related previleges" |
| 84 | +complete -c usbguard -n "__fish_seen_subcommand_from add-user" -s "d" -l "devices" -d "Device related privileges" |
| 85 | +complete -c usbguard -n "__fish_seen_subcommand_from add-user" -s "e" -l "exceptions" -d "Exceptions related privileges" |
| 86 | +complete -c usbguard -n "__fish_seen_subcommand_from add-user" -s "P" -l "parameters" -d "Run-time parameter related privileges" |
0 commit comments