Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions analysis_options_release.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions lib/cli/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ part "paths.dart";

class CliContext implements Disposable {
static late final CliContext I;
static bool _instanced = false;

factory(Iterable<String> arguments) {
if (_instanced) return I;
_instanced = true;

final bool debug = arguments.contains("--debug");

return I = ._(
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/wait.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ final class WaitCommand extends Command<void> with Disposable {
Future<void> run() async {
if (argResults!.rest.firstOrNull case final seconds?) {
if (int.tryParse(seconds) case final seconds? when seconds.isPositive) {
context.printer("Waiting ${seconds}s...");
final spin = context.printer.spin(text: "Waiting ${seconds}s...");
await Future.delayed(.new(seconds: seconds));
context.printer("Completed.");
spin.success("Completed.");
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions lib/extensions/io_http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ extension HttpClientResponseExtension on HttpClientResponse {
return Isolate.run(() => jsonDecode(body));
}
}

extension HttpHeadersExtension on HttpHeaders {
static const _apiTokenHeader = "api-token";

String? get apiToken => value(_apiTokenHeader);

set apiToken(String value) => set(_apiTokenHeader, value);
}
7 changes: 3 additions & 4 deletions lib/services/discloud/api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ class DiscloudApiClient implements Disposable {
return null;
}

factory({HttpClient? client}) =>
DiscloudApiClient._(client: client ?? .new());
factory({HttpClient? client}) => ._(client: client ?? .new());

const new _({required this._client});

Expand Down Expand Up @@ -347,12 +346,12 @@ class DiscloudApiClient implements Disposable {

if (!hasApiToken) {
if (await _maybeToken case final value?) {
request.headers.set(_apiTokenHeader, value);
request.headers.apiToken = value;
sb.writeln("[Request] Header: $_apiTokenHeader:${value.length}");
}
}

if (!isDiscloudJwt(request.headers.value(_apiTokenHeader).orEmpty)) {
if (!isDiscloudJwt(request.headers.apiToken.orEmpty)) {
_context.printer.debug(sb);
throw const DiscloudApiException(
code: 401,
Expand Down