šŸ“¦āž”šŸ¦‹ Store and retrieve files on the Atmosphere
34
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 185 lines 7.0 kB view raw
1#!/usr/bin/env bash 2 3function atfile.invoke() { 4 command="$1" 5 shift 6 args=("$@") 7 8 # shellcheck disable=SC2154 9 if [[ $_is_sourced == 0 ]] && [[ $ATFILE_DEVEL_NO_INVOKE != 1 ]]; then 10 atfile.say.debug "Invoking '$command'...\n↳ Arguments: ${args[*]}" 11 12 case "$command" in 13 "ai") 14 atfile.ai 15 ;; 16 "blob") 17 case "${args[0]}" in 18 "list"|"ls"|"l") atfile.invoke.blob_list "${args[1]}" ;; 19 "upload"|"u") atfile.invoke.blob_upload "${args[1]}" ;; 20 *) atfile.die.unknown_command "$(echo "$command ${args[0]}" | xargs)" ;; 21 esac 22 ;; 23 "bsky") 24 if [[ -z "${args[0]}" ]]; then 25 atfile.util.override_actor "$_username" 26 atfile.bsky_profile "$_username" 27 else 28 atfile.bsky_profile "${args[0]}" 29 fi 30 ;; 31 "build") 32 if [[ $ATFILE_DEVEL == 1 ]]; then 33 atfile.build 34 else 35 atfile.die.unknown_command "$command" 36 fi 37 ;; 38 "cat") 39 [[ -z "${args[0]}" ]] && atfile.die "<key> not set" 40 if [[ -n "${args[1]}" ]]; then 41 atfile.util.override_actor "${args[1]}" 42 fi 43 44 atfile.invoke.print "${args[0]}" 45 ;; 46 "delete") 47 [[ -z "${args[0]}" ]] && atfile.die "<key> not set" 48 atfile.invoke.delete "${args[0]}" 49 ;; 50 "fetch") 51 [[ -z "${args[0]}" ]] && atfile.die "<key> not set" 52 if [[ -n "${args[1]}" ]]; then 53 atfile.util.override_actor "${args[1]}" 54 fi 55 56 atfile.invoke.download "${args[0]}" 57 ;; 58 "fetch-crypt") 59 atfile.util.check_prog_gpg 60 [[ -z "${args[0]}" ]] && atfile.die "<key> not set" 61 if [[ -n "${args[1]}" ]]; then 62 atfile.util.override_actor "${args[1]}" 63 fi 64 65 atfile.invoke.download "${args[0]}" 1 66 ;; 67 "handle") 68 uri="${args[0]}" 69 protocol="$(atfile.util.get_uri_segment "$uri" protocol)" 70 71 atfile.say.debug "Handling protocol '$protocol://'..." 72 73 case $protocol in 74 "at") 75 atfile.say.debug "Launching '$uri' in PDSls ($_endpoint_pdsls)..." 76 atfile.util.launch_uri "$_endpoint_pdsls/$uri" 77 ;; 78 "atfile") 79 atfile.handle "$uri" "${args[1]}" 80 ;; 81 esac 82 ;; 83 "help") 84 atfile.help 85 ;; 86 "info") 87 [[ -z "${args[0]}" ]] && atfile.die "<key> not set" 88 if [[ -n "${args[1]}" ]]; then 89 atfile.util.override_actor "${args[1]}" 90 fi 91 92 atfile.invoke.get "${args[0]}" 93 ;; 94 "install") 95 # TODO: Disable when installed (how?), similar to `release` 96 atfile.install "${args[0]}" "${args[1]}" "${args[2]}" 97 ;; 98 "list") 99 if [[ "${args[0]}" == *.* || "${args[0]}" == did:* ]]; then 100 # NOTE: User has entered <actor> in the wrong place, so we'll fix it 101 # for them 102 # BUG: Keys with periods in them can't be used as a cursor 103 104 atfile.util.override_actor "${args[0]}" 105 106 atfile.invoke.list "${args[1]}" 107 else 108 if [[ -n "${args[1]}" ]]; then 109 atfile.util.override_actor "${args[1]}" 110 fi 111 atfile.invoke.list "${args[0]}" 112 fi 113 ;; 114 "lock") 115 atfile.invoke.lock "${args[0]}" 1 116 ;; 117 "now") 118 atfile.now "${args[0]}" 119 ;; 120 "record") 121 # NOTE: Performs no validation (apart from JSON)! Here be dragons 122 case "${args[0]}" in 123 "add"|"create"|"c") atfile.record "create" "${args[1]}" "${args[2]}" ;; 124 "get"|"g") atfile.record "get" "${args[1]}" ;; 125 "ls"|"list"|"l") atfile.record_list "${args[1]}" ;; 126 "put"|"update"|"u") atfile.record "update" "${args[1]}" "${args[2]}" ;; 127 "rc"|"recreate"|"r") atfile.record "recreate" "${args[1]}" "${args[2]}" ;; 128 "rm"|"delete"|"d") atfile.record "delete" "${args[1]}" ;; 129 *) atfile.die.unknown_command "$(echo "$command ${args[0]}" | xargs)" ;; 130 esac 131 ;; 132 "resolve") 133 atfile.resolve "${args[0]}" 134 ;; 135 "something-broke") 136 atfile.something_broke 137 ;; 138 "stream") 139 atfile.stream "${args[0]}" "${args[1]}" "${args[2]}" "${args[3]}" 140 ;; 141 "token") 142 atfile.token 143 ;; 144 "toggle-mime") 145 atfile.toggle_desktop 146 ;; 147 "upload") 148 atfile.util.check_prog_optional_metadata 149 [[ -z "${args[0]}" ]] && atfile.die "<file> not set" 150 atfile.invoke.upload "${args[0]}" "" "${args[1]}" 151 ;; 152 "upload-crypt") 153 atfile.util.check_prog_optional_metadata 154 atfile.util.check_prog_gpg 155 [[ -z "${args[0]}" ]] && atfile.die "<file> not set" 156 [[ -z "${args[1]}" ]] && atfile.die "<recipient> not set" 157 atfile.invoke.upload "${args[0]}" "${args[1]}" "${args[2]}" 158 ;; 159 "unlock") 160 atfile.invoke.lock "${args[0]}" 0 161 ;; 162 "update") 163 atfile.update install 164 ;; 165 "url") 166 [[ -z "${args[0]}" ]] && atfile.die "<key> not set" 167 if [[ -n "${args[1]}" ]]; then 168 atfile.util.override_actor "${args[1]}" 169 fi 170 171 atfile.invoke.get_url "${args[0]}" 172 ;; 173 "version") 174 echo -e "$_version" 175 atfile.cache.del "update-check" 176 atfile.update check-only 177 ;; 178 *) 179 atfile.die.unknown_command "$command" 180 ;; 181 esac 182 183 atfile.update check-only 184 fi 185}