mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-08 23:54:39 +00:00
no empty methods
use constants instead of repeating strings
This commit is contained in:
+6
-2
@@ -91,13 +91,17 @@ abstract class FlowProgressForegroundService<T> : Service() {
|
||||
protected abstract fun cancelAll()
|
||||
|
||||
/** Called for every emission before [render]; use to update derived subclass state. */
|
||||
protected open fun onEmission(value: T) {}
|
||||
protected open fun onEmission(value: T) {
|
||||
// No-op by default: only subclasses that keep derived state need this hook.
|
||||
}
|
||||
|
||||
/** Only consulted for the [refreshMs] clock loop; skip re-renders when nothing is moving. */
|
||||
protected open fun needsClockRefresh(value: T): Boolean = true
|
||||
|
||||
/** One-time setup once the watch loop starts (e.g. a benchmark). */
|
||||
protected open fun onStarted() {}
|
||||
protected open fun onStarted() {
|
||||
// No-op by default: only subclasses with one-time setup (e.g. a benchmark) override this.
|
||||
}
|
||||
|
||||
/** How to draw the progress bar of the card. */
|
||||
sealed interface Bar {
|
||||
|
||||
@@ -164,8 +164,11 @@ class AwaitTimeout(
|
||||
*/
|
||||
private val STRICT_ACCOUNT_VERBS = setOf("init", "create", "login", "logoff", "whoami")
|
||||
|
||||
private const val HELP_FLAG = "--help"
|
||||
private const val HELP_FLAG_SHORT = "-h"
|
||||
|
||||
private suspend fun dispatch(argv: Array<String>): Int {
|
||||
if (argv.firstOrNull() == "--help" || argv.firstOrNull() == "-h") {
|
||||
if (argv.firstOrNull() == HELP_FLAG || argv.firstOrNull() == HELP_FLAG_SHORT) {
|
||||
printUsage()
|
||||
return 0
|
||||
}
|
||||
@@ -203,9 +206,9 @@ private suspend fun dispatch(argv: Array<String>): Int {
|
||||
// becomes a plain leading --help, so `amy notes post "hi" --help` prints
|
||||
// usage instead of publishing, and no command can forget to honor it.
|
||||
// (`--` still lets you pass the literal text: `amy notes post -- --help`.)
|
||||
val helpIdx = tail.indexOfFirst { it == "--" || it == "--help" || it == "-h" }
|
||||
val helpIdx = tail.indexOfFirst { it == "--" || it == HELP_FLAG || it == HELP_FLAG_SHORT }
|
||||
if (helpIdx >= 0 && tail[helpIdx] != "--") {
|
||||
tail = arrayOf("--help")
|
||||
tail = arrayOf(HELP_FLAG)
|
||||
}
|
||||
|
||||
// `use` operates on `<root>/current` directly and must work even
|
||||
|
||||
@@ -137,7 +137,7 @@ object DmCommands {
|
||||
): Int {
|
||||
val args = Args(rest)
|
||||
val allowFallback = args.bool("allow-fallback")
|
||||
args.rejectUnknown("file", "server", "mime-type", "key", "nonce", "hash", "original-hash", "size", "dim", "blurhash")
|
||||
args.rejectUnknown("file", "server", FLAG_MIME_TYPE, "key", "nonce", "hash", "original-hash", "size", "dim", "blurhash")
|
||||
val recipientInput = args.positionalOrNull(0) ?: return Output.error("bad_args", USAGE_SEND_FILE)
|
||||
|
||||
Context.open(dataDir).use { ctx ->
|
||||
@@ -186,7 +186,7 @@ object DmCommands {
|
||||
Output.error("upload_failed", "Blossom server $server returned no URL")
|
||||
return null
|
||||
}
|
||||
val mimeType = args.flag("mime-type") ?: uploaded.metadata.mimeType
|
||||
val mimeType = args.flag(FLAG_MIME_TYPE) ?: uploaded.metadata.mimeType
|
||||
val dimension =
|
||||
uploaded.metadata.width?.let { w ->
|
||||
uploaded.metadata.height?.let { h ->
|
||||
@@ -247,7 +247,7 @@ object DmCommands {
|
||||
Output.error("bad_args", "--nonce must be hex (got ${nonceHex.length} chars)")
|
||||
return null
|
||||
}
|
||||
val mimeType = args.flag("mime-type")
|
||||
val mimeType = args.flag(FLAG_MIME_TYPE)
|
||||
val hash = args.flag("hash")
|
||||
val originalHash = args.flag("original-hash")
|
||||
val size = args.flag("size")?.toIntOrNull()
|
||||
@@ -282,6 +282,8 @@ object DmCommands {
|
||||
return result to emptyMap()
|
||||
}
|
||||
|
||||
private const val FLAG_MIME_TYPE = "mime-type"
|
||||
|
||||
private const val USAGE_SEND_FILE: String =
|
||||
"dm send-file <recipient> [--file PATH --server URL | URL --key HEX --nonce HEX] " +
|
||||
"[--mime-type M] [--hash HEX] [--original-hash HEX] [--size N] [--dim WxH] [--blurhash S] [--allow-fallback]"
|
||||
|
||||
Reference in New Issue
Block a user