Skip to content

Commit

Permalink
[ Edit ]exposed docs links for the convenable commands
Browse files Browse the repository at this point in the history
  • Loading branch information
anasfik committed Oct 5, 2023
1 parent 6a8d84e commit 35cf93e
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 24 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

- Changed the account creation command from `apiKey` to `create` for more consistency.

# 0.8.2
# 0.8.3

- Added info debug command for seeing the variables while developing, it should not be shown in the production version.
Binary file modified bin/langsync.exe
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ class AuthCommand extends Command<int> {
return ExitCode.ioError.code;
}
} else {
logger.err('The API key you provided is not valid, please try again.');
logger
..err('The API key you provided is not valid, please try again.')
..docsInfo(path: '/cli-usage/auth');

return ExitCode.ioError.code;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ class InfoCommand extends Command<int> {
commandName: name,
);

logger.info('\n');
logger.warn(
'This error has been reported to the LangSync team, we will definitely look into it!',
);
logger
..info('\n')
..warn(
'This error has been reported to the LangSync team, we will definitely look into it!',
);
} catch (e) {}

return ExitCode.software.code;
Expand Down
18 changes: 11 additions & 7 deletions lib/src/commands/account_command/sub_commands/logout_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class LogoutCommand extends Command<int> {
final apiKey = configBox.get('apiKey') as String?;

if (apiKey == null) {
logger.info('No account was associated with the CLI.');
logger
..info('No account was logged in previously.')
..docsInfo(path: '/cli-usage/auth');

return ExitCode.success.code;
} else {
Expand All @@ -33,7 +35,9 @@ class LogoutCommand extends Command<int> {
);

if (!confirm) {
logger.info('Logout aborted.');
logger
..info('Logout aborted.')
..docsInfo(path: '/cli-usage/auth');

return ExitCode.success.code;
}
Expand All @@ -59,11 +63,11 @@ class LogoutCommand extends Command<int> {
stacktrace: stacktrace,
commandName: name,
);
logger.info('\n');

logger.warn(
'This error has been reported to the LangSync team, we will definitely look into it!',
);
logger
..info('\n')
..warn(
'This error has been reported to the LangSync team, we will definitely look into it!',
);
} catch (e) {}

return ExitCode.ioError.code;
Expand Down
18 changes: 12 additions & 6 deletions lib/src/commands/config_command/sub_commands/create_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class ConfigCreateCommand extends Command<int> {
await file.delete();

deleteLogger.complete(
'The already existing langsync.yaml file is deleted successfully',);
'The already existing langsync.yaml file is deleted successfully',
);

return run();
} else {
Expand All @@ -68,9 +69,11 @@ class ConfigCreateCommand extends Command<int> {
final sourceFile = File(sourceLocalizationFilePath);

if (!sourceFile.existsSync()) {
logger.err(
'''The source localization file at $sourceLocalizationFilePath does not exist.''',
);
logger
..err(
'The source localization file at $sourceLocalizationFilePath does not exist.',
)
..docsInfo(path: '/cli-usage/configure');

return ExitCode.software.code;
}
Expand All @@ -96,7 +99,10 @@ class ConfigCreateCommand extends Command<int> {
'The output directory is created successfully.',
);
} else {
logger.info('Aborting');
logger
..info('Aborting')
..docsInfo(path: '/cli-usage/configure');

return ExitCode.success.code;
}
}
Expand Down Expand Up @@ -132,7 +138,7 @@ class ConfigCreateCommand extends Command<int> {
await YamlController.createConfigFile();

creationProgress.update(
'langsync.yaml file IS created, updating it with your config...',
'langsync.yaml file is created, updating it with your config...',
);

await YamlController.writeToConfigFile('langsync:\n');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class ConfigValidateCommand extends Command<int> {
if (!YamlController.configFileRef.existsSync()) {
logger
..info('There is no langsync.yaml file in the current directory.')
..info('Run `langsync config create` to create one.');
..info('Run `langsync config create` to create one.')
..docsInfo(path: '/cli-usage/configure');

return ExitCode.success.code;
}
Expand Down Expand Up @@ -62,7 +63,8 @@ class ConfigValidateCommand extends Command<int> {
'''
Please check your langsync.yaml file, or run `langsync config create` to create a new one.
''',
);
)
..docsInfo(path: '/cli-usage/configure');

return ExitCode.software.code;
}
Expand Down
1 change: 1 addition & 0 deletions lib/src/commands/debug_info/debug_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import 'dart:async';

import 'package:args/command_runner.dart';
import 'package:http/http.dart';
import 'package:langsync/src/etc/utils.dart';
import 'package:langsync/src/version.dart';
import 'package:mason_logger/mason_logger.dart';
Expand Down
7 changes: 6 additions & 1 deletion lib/src/commands/start_command/start_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ class StartCommand extends Command<int> {

if (apiKey == null) {
configFilesValidationProgress.fail(
'You need to authenticate first with your account API key, see Docs.',
'You need to authenticate first with your account API key.',
);

logger.docsInfo(path: '/cli-usage/auth');

return ExitCode.config.code;
}

Expand All @@ -46,6 +48,8 @@ class StartCommand extends Command<int> {
'No langsync.yaml file found, you need to create one and configure it.',
);

logger.docsInfo(path: '/cli-usage/configure');

return ExitCode.config.code;
}

Expand All @@ -57,6 +61,7 @@ class StartCommand extends Command<int> {
configFilesValidationProgress.update('Validating langsync.yaml file..');

YamlController.validateConfigFields(parsedYaml);

configFilesValidationProgress
.complete('Your langsync.yaml file and configuration are valid.');
} catch (e, stacktrace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class SupportedLangsCommand extends Command<int> {
langPrompt = langPrompt.trim();

if (langPrompt.isEmpty) {
logger.err('No language(s) provided.');
logger
..err('No language(s) provided.')
..docsInfo(path: '/cli-usage/check_launguages_support');

return ExitCode.usage.code;
} else {
final langs = langPrompt.split(',').map((e) => e.trim()).toList();
Expand Down
9 changes: 9 additions & 0 deletions lib/src/etc/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ extension DateExte on DateTime {
}

extension LoggerExt on Logger {
void docsInfo({
required String path,
}) {
info('\n');
info(
"For more info, check our docs at: https://docs.langsync.app/${path.startsWith('/') ? path.substring(1) : path}",
);
}

void customErr({
required Progress progress,
required String update,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/etc/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Utils {
}

String endpoint(String path) {
return 'baseUrl${path.startsWith("/") ? path : "/$path"}';
return '$baseUrl${path.startsWith("/") ? path : "/$path"}';
}

List<String> randomLoadingFrames() {
Expand Down

0 comments on commit 35cf93e

Please sign in to comment.