• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Crystal library and CLI tool for Catbox.moe


Commit MetaInfo

Revision3c5ff3d4a8cb37b9eb529d0b709413e0bdde95a0 (tree)
Time2023-03-30 23:53:39
AuthorRemilia Scarlet <remilia@post...>
CommiterRemilia Scarlet

Log Message

Update to a newer libremiliacr version. Update copyright headers.

Change Summary

Incremental Difference

diff -r 9124e4d13bd9 -r 3c5ff3d4a8cb shard.lock
--- a/shard.lock Mon Nov 08 02:17:33 2021 -0700
+++ b/shard.lock Thu Mar 30 08:53:39 2023 -0600
@@ -1,6 +1,6 @@
11 version: 2.0
22 shards:
33 libremiliacr:
4- git: https://gitlab.com/remiliascarlet/libremiliacr.git
5- version: 0.4.7
4+ fossil: https://chiselapp.com/user/MistressRemilia/repository/libremiliacr
5+ version: 0.9.0
66
diff -r 9124e4d13bd9 -r 3c5ff3d4a8cb shard.yml
--- a/shard.yml Mon Nov 08 02:17:33 2021 -0700
+++ b/shard.yml Thu Mar 30 08:53:39 2023 -0600
@@ -12,5 +12,5 @@
1212
1313 dependencies:
1414 libremiliacr:
15- gitlab: RemiliaScarlet/libremiliacr
16- version: ~> 0.4.7
15+ fossil: https://chiselapp.com/user/MistressRemilia/repository/libremiliacr
16+ version: ~> 0.9.0
diff -r 9124e4d13bd9 -r 3c5ff3d4a8cb src/remicatbox.cr
--- a/src/remicatbox.cr Mon Nov 08 02:17:33 2021 -0700
+++ b/src/remicatbox.cr Thu Mar 30 08:53:39 2023 -0600
@@ -1,5 +1,5 @@
11 #### RemiCatbox - A library to interact with Catbox.
2-#### Copyright (C) 2021 Remilia Scarlet
2+#### Copyright (C) 2021-2023 Remilia Scarlet
33 ####
44 #### This program is free software: you can redistribute it and/or modify it
55 #### under the terms of the GNU Affero General Public License as published by
diff -r 9124e4d13bd9 -r 3c5ff3d4a8cb tools/catboxtool.cr
--- a/tools/catboxtool.cr Mon Nov 08 02:17:33 2021 -0700
+++ b/tools/catboxtool.cr Thu Mar 30 08:53:39 2023 -0600
@@ -1,5 +1,5 @@
11 #### CatboxTool - A CLI tool to interact with Catbox.
2-#### Copyright (C) 2021 Remilia Scarlet
2+#### Copyright (C) 2021-2023 Remilia Scarlet
33 ####
44 #### This program is free software: you can redistribute it and/or modify it
55 #### under the terms of the GNU Affero General Public License as published by
@@ -14,8 +14,7 @@
1414 #### You should have received a copy of the GNU Affero General Public License
1515 #### along with this program. If not, see <https://www.gnu.org/licenses/>.
1616 require "../src/remicatbox"
17-require "libremiliacr/remiargparser"
18-require "libremiliacr/remilog"
17+require "libremiliacr"
1918 require "json"
2019
2120 module CatboxTool
@@ -35,7 +34,7 @@
3534 end
3635
3736 class Program
38- getter args = RemiArgParser::ArgParser.new("catboxtool", VERSION)
37+ getter args = RemiLib::Args::ArgParser.new("catboxtool", VERSION)
3938 @userHash : String? = nil
4039 @files = [] of String
4140
@@ -47,9 +46,9 @@
4746 # Load config and get a user hash
4847 config = loadConfig
4948 @userHash = config.userHash
50- if args["user-hash"].called
49+ if args["user-hash"].called?
5150 @userHash = args["user-hash"].str
52- elsif args["no-user-hash"].called
51+ elsif args["no-user-hash"].called?
5352 @userHash = nil
5453 end
5554
@@ -57,23 +56,23 @@
5756
5857 # We'll need a user hash for certain operations
5958 unless @userHash
60- if args["album-edit"].called || args["album-delete"].called
61- RemiLog.log.fatal("A user hash is required to edit or delete albums")
59+ if args["album-edit"].called? || args["album-delete"].called?
60+ RemiLib.log.fatal("A user hash is required to edit or delete albums")
6261 end
6362 end
6463
6564 # Do one of the possible operations.
66- if args["album"].called
65+ if args["album"].called?
6766 case
68- when args["album-delete"].called then deleteAlbum
69- when args["album-edit"].called then editAlbum
70- when args["album-add"].called then albumAdd
71- when args["album-remove"].called then albumRemove
67+ when args["album-delete"].called? then deleteAlbum
68+ when args["album-edit"].called? then editAlbum
69+ when args["album-add"].called? then albumAdd
70+ when args["album-remove"].called? then albumRemove
7271 end
7372 else
7473 case
75- when args["delete"].called then deleteFiles
76- when args["album-title"].called then uploadToAlbum
74+ when args["delete"].called? then deleteFiles
75+ when args["album-title"].called? then uploadToAlbum
7776 else uploadStuff
7877 end
7978 end
@@ -90,7 +89,7 @@
9089 if File.exists?(file)
9190 puts "Uploading #{Path[file].basename}..."
9291 else
93- RemiLog.log.error("File not found: #{file}")
92+ RemiLib.log.error("File not found: #{file}")
9493 next
9594 end
9695 end
@@ -100,7 +99,7 @@
10099 if code == 200
101100 uploaded << result
102101 else
103- RemiLog.log.error("Could not upload #{file}: #{result}")
102+ RemiLib.log.error("Could not upload #{file}: #{result}")
104103 end
105104 end
106105
@@ -115,7 +114,7 @@
115114
116115 # Uploads things into a new album
117116 private def uploadToAlbum
118- albumDesc = args["album-desc"].called ? args["album-desc"].str : nil
117+ albumDesc = args["album-desc"].called? ? args["album-desc"].str : nil
119118
120119 puts "Uploading things to new album..."
121120 begin
@@ -123,7 +122,7 @@
123122
124123 # Print any URLs that were generated during the initial file upload
125124 if newUrls.empty?
126- RemiLog.log.fatal("No files could be uploaded")
125+ RemiLib.log.fatal("No files could be uploaded")
127126 else
128127 puts "URLs: "
129128 newUrls.each { |url| puts " #{url}" }
@@ -133,10 +132,10 @@
133132 if code == 200
134133 puts "Album: #{result}"
135134 else
136- RemiLog.log.error("Could not create an album from the uploads: #{result}")
135+ RemiLib.log.error("Could not create an album from the uploads: #{result}")
137136 end
138137 rescue err : Exception
139- RemiLog.log.error("#{err}")
138+ RemiLib.log.error("#{err}")
140139 end
141140 end
142141
@@ -148,7 +147,7 @@
148147 if code == 200
149148 puts "Success"
150149 else
151- RemiLog.log.fatal("Could not delete album: #{result}")
150+ RemiLib.log.fatal("Could not delete album: #{result}")
152151 end
153152 end
154153
@@ -162,46 +161,46 @@
162161 if code == 200
163162 puts "Success: #{result}"
164163 else
165- RemiLog.log.fatal("Could not edit album: #{result}")
164+ RemiLib.log.fatal("Could not edit album: #{result}")
166165 end
167166 end
168167
169168 # Adds files already uploaded to Catbox to an existing album
170169 private def albumAdd
171- RemiLog.log.fatal("No files specified to add to an album") if @files.empty?
170+ RemiLib.log.fatal("No files specified to add to an album") if @files.empty?
172171 puts "Adding #{@files.size} file#{@files.size == 1 ? "" : "s"} to album #{args["album"].str}..."
173172 result, code = RemiCatbox.addToAlbum(args["album"].str, @userHash.not_nil!, @files)
174173
175174 if code == 200
176175 puts "Success: #{result}"
177176 else
178- RemiLog.log.fatal("Could not add files to album: #{result}")
177+ RemiLib.log.fatal("Could not add files to album: #{result}")
179178 end
180179 end
181180
182181 # Removes files from an album
183182 private def albumRemove
184- RemiLog.log.fatal("No files specified to remove from an album") if @files.empty?
183+ RemiLib.log.fatal("No files specified to remove from an album") if @files.empty?
185184 puts "Removing #{@files.size} file#{@files.size == 1 ? "" : "s"} from album #{args["album"].str}..."
186185 result, code = RemiCatbox.removeFromAlbum(args["album"].str, @userHash.not_nil!, @files)
187186
188187 if code == 200
189188 puts "Success: #{result}"
190189 else
191- RemiLog.log.fatal("Could not remove files from album: #{result}")
190+ RemiLib.log.fatal("Could not remove files from album: #{result}")
192191 end
193192 end
194193
195194 # Deletes files from Catbox
196195 private def deleteFiles
197196 puts "Deleting #{@files.size} file#{@files.size == 1 ? "" : "s"}..."
198- RemiLog.log.fatal("No files specified for deletion") if @files.empty?
197+ RemiLib.log.fatal("No files specified for deletion") if @files.empty?
199198 result, code = RemiCatbox.deleteFiles(@userHash.not_nil!, @files)
200199
201200 if code == 200
202201 puts "Success: #{result}"
203202 else
204- RemiLog.log.fatal("Could not delete files: #{result}")
203+ RemiLib.log.fatal("Could not delete files: #{result}")
205204 end
206205 end
207206
@@ -230,16 +229,16 @@
230229 # Add the arguments
231230 args.addFlag("delete", 'D', help: "Deletes files instead of uploading them. A userhash is required.")
232231
233- args.addString("user-hash", 'u', "Users", "Use a userhash for the upload")
234- args.addFlag("no-user-hash", 'A', "Users", "Do not use the userhash in the config file if it exists")
232+ args.addString("user-hash", 'u', group: "Users", help: "Use a userhash for the upload")
233+ args.addFlag("no-user-hash", 'A', group: "Users", help: "Do not use the userhash in the config file if it exists")
235234
236- args.addString("album", 'a', "Albums", "Manage an existing album with the given short code")
237- args.addString("album-title", 't', "Albums", "Sets an album's title")
238- args.addString("album-desc", 'd', "Albums", "Sets an album's description")
239- args.addFlag("album-add", nil, "Albums", "Adds the files to the album referenced with --album")
240- args.addFlag("album-remove", nil, "Albums", "Removes the files from the album referenced with --album")
241- args.addFlag("album-delete", nil, "Albums", "Deletes the album referenced with --album")
242- args.addFlag("album-edit", nil, "Albums", "Modifies the album referenced with --album")
235+ args.addString("album", 'a', group: "Albums", help: "Manage an existing album with the given short code")
236+ args.addString("album-title", 't', group: "Albums", help: "Sets an album's title")
237+ args.addString("album-desc", 'd', group: "Albums", help: "Sets an album's description")
238+ args.addFlag("album-add", nil, group: "Albums", help: "Adds the files to the album referenced with --album")
239+ args.addFlag("album-remove", nil, group: "Albums", help: "Removes the files from the album referenced with --album")
240+ args.addFlag("album-delete", nil, group: "Albums", help: "Deletes the album referenced with --album")
241+ args.addFlag("album-edit", nil, group: "Albums", help: "Modifies the album referenced with --album")
243242
244243 args.postHelpText = %{
245244 If a user hash is specified in the configuration file, then it is used for all
@@ -254,38 +253,38 @@
254253 # Parse command line
255254 begin
256255 args.parse
257- rescue err : RemiArgParser::ArgumentError
258- RemiLog.log.fatal("#{err}")
256+ rescue err : RemiLib::Args::ArgumentError
257+ RemiLib.log.fatal("#{err}")
259258 end
260259
261260 # Check argument combinations and other conditions
262- if args.positionalArgs.empty? && !(args["album-delete"].called || args["album-edit"].called)
263- RemiLog.log.fatal("Nothing to upload or manage")
261+ if args.positionalArgs.empty? && !(args["album-delete"].called? || args["album-edit"].called?)
262+ RemiLib.log.fatal("Nothing to upload or manage")
264263 end
265264
266- if args["no-user-hash"].called
267- RemiLog.log.fatal("Cannot use --user-hash and --no-user-hash together") if args["user-hash"].called
268- RemiLog.log.fatal("Cannot use --delete and --no-user-hash together") if args["delete"].called
269- RemiLog.log.fatal("Cannot use --album-edit and --no-user-hash together") if args["album-edit"].called
270- RemiLog.log.fatal("Cannot use --album-delete and --no-user-hash together") if args["album-delete"].called
265+ if args["no-user-hash"].called?
266+ RemiLib.log.fatal("Cannot use --user-hash and --no-user-hash together") if args["user-hash"].called?
267+ RemiLib.log.fatal("Cannot use --delete and --no-user-hash together") if args["delete"].called?
268+ RemiLib.log.fatal("Cannot use --album-edit and --no-user-hash together") if args["album-edit"].called?
269+ RemiLib.log.fatal("Cannot use --album-delete and --no-user-hash together") if args["album-delete"].called?
271270 end
272271
273- unless args["album"].called
274- RemiLog.log.fatal("--album-edit requires an album short code") if args["album-edit"].called
275- RemiLog.log.fatal("--album-delete requires an album short code") if args["album-delete"].called
276- RemiLog.log.fatal("--album-add requires an album short code") if args["album-add"].called
277- RemiLog.log.fatal("--album-remove requires an album short code") if args["album-remove"].called
272+ unless args["album"].called?
273+ RemiLib.log.fatal("--album-edit requires an album short code") if args["album-edit"].called?
274+ RemiLib.log.fatal("--album-delete requires an album short code") if args["album-delete"].called?
275+ RemiLib.log.fatal("--album-add requires an album short code") if args["album-add"].called?
276+ RemiLib.log.fatal("--album-remove requires an album short code") if args["album-remove"].called?
278277 end
279278
280- if args["album-desc"].called
281- unless (args["album"].called && args["album-edit"].called) || args["album-title"].called
282- RemiLog.log.fatal("--album-desc can only be used when creating or editing an album")
279+ if args["album-desc"].called?
280+ unless (args["album"].called? && args["album-edit"].called?) || args["album-title"].called?
281+ RemiLib.log.fatal("--album-desc can only be used when creating or editing an album")
283282 end
284283 end
285284
286- if args["delete"].called
287- RemiLog.log.fatal("Cannot use --delete with --album") if args["album"].called
288- RemiLog.log.fatal("Cannot use --delete with --album-title") if args["album-title"].called
285+ if args["delete"].called?
286+ RemiLib.log.fatal("Cannot use --delete with --album") if args["album"].called?
287+ RemiLib.log.fatal("Cannot use --delete with --album-title") if args["album-title"].called?
289288 end
290289 end
291290