diff --git a/CHANGELOG b/CHANGELOG index 77287b5..1ab796e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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. \ No newline at end of file diff --git a/bin/langsync.exe b/bin/langsync.exe index f1b0ede..a9b9e9a 100644 Binary files a/bin/langsync.exe and b/bin/langsync.exe differ diff --git a/lib/src/commands/account_command/sub_commands/auth_command.dart b/lib/src/commands/account_command/sub_commands/auth_command.dart index a1c5e3d..593c349 100644 --- a/lib/src/commands/account_command/sub_commands/auth_command.dart +++ b/lib/src/commands/account_command/sub_commands/auth_command.dart @@ -76,7 +76,9 @@ class AuthCommand extends Command { 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; } diff --git a/lib/src/commands/account_command/sub_commands/info_command.dart b/lib/src/commands/account_command/sub_commands/info_command.dart index 3810340..3875e8e 100644 --- a/lib/src/commands/account_command/sub_commands/info_command.dart +++ b/lib/src/commands/account_command/sub_commands/info_command.dart @@ -78,10 +78,11 @@ class InfoCommand extends Command { 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; diff --git a/lib/src/commands/account_command/sub_commands/logout_command.dart b/lib/src/commands/account_command/sub_commands/logout_command.dart index 2bfe27c..c4ab874 100644 --- a/lib/src/commands/account_command/sub_commands/logout_command.dart +++ b/lib/src/commands/account_command/sub_commands/logout_command.dart @@ -24,7 +24,9 @@ class LogoutCommand extends Command { 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 { @@ -33,7 +35,9 @@ class LogoutCommand extends Command { ); if (!confirm) { - logger.info('Logout aborted.'); + logger + ..info('Logout aborted.') + ..docsInfo(path: '/cli-usage/auth'); return ExitCode.success.code; } @@ -59,11 +63,11 @@ class LogoutCommand extends Command { 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; diff --git a/lib/src/commands/config_command/sub_commands/create_command.dart b/lib/src/commands/config_command/sub_commands/create_command.dart index 6924e67..abc8d59 100644 --- a/lib/src/commands/config_command/sub_commands/create_command.dart +++ b/lib/src/commands/config_command/sub_commands/create_command.dart @@ -50,7 +50,8 @@ class ConfigCreateCommand extends Command { 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 { @@ -68,9 +69,11 @@ class ConfigCreateCommand extends Command { 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; } @@ -96,7 +99,10 @@ class ConfigCreateCommand extends Command { 'The output directory is created successfully.', ); } else { - logger.info('Aborting'); + logger + ..info('Aborting') + ..docsInfo(path: '/cli-usage/configure'); + return ExitCode.success.code; } } @@ -132,7 +138,7 @@ class ConfigCreateCommand extends Command { 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'); diff --git a/lib/src/commands/config_command/sub_commands/validate_command.dart b/lib/src/commands/config_command/sub_commands/validate_command.dart index e71c166..700acb6 100644 --- a/lib/src/commands/config_command/sub_commands/validate_command.dart +++ b/lib/src/commands/config_command/sub_commands/validate_command.dart @@ -23,7 +23,8 @@ class ConfigValidateCommand extends Command { 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; } @@ -62,7 +63,8 @@ class ConfigValidateCommand extends Command { ''' 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; } diff --git a/lib/src/commands/debug_info/debug_info.dart b/lib/src/commands/debug_info/debug_info.dart index 476b013..ac2b454 100644 --- a/lib/src/commands/debug_info/debug_info.dart +++ b/lib/src/commands/debug_info/debug_info.dart @@ -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'; diff --git a/lib/src/commands/start_command/start_command.dart b/lib/src/commands/start_command/start_command.dart index c3d151e..841f67a 100644 --- a/lib/src/commands/start_command/start_command.dart +++ b/lib/src/commands/start_command/start_command.dart @@ -35,9 +35,11 @@ class StartCommand extends Command { 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; } @@ -46,6 +48,8 @@ class StartCommand extends Command { 'No langsync.yaml file found, you need to create one and configure it.', ); + logger.docsInfo(path: '/cli-usage/configure'); + return ExitCode.config.code; } @@ -57,6 +61,7 @@ class StartCommand extends Command { configFilesValidationProgress.update('Validating langsync.yaml file..'); YamlController.validateConfigFields(parsedYaml); + configFilesValidationProgress .complete('Your langsync.yaml file and configuration are valid.'); } catch (e, stacktrace) { diff --git a/lib/src/commands/supported_laungages_command/supported_laungages_command.dart b/lib/src/commands/supported_laungages_command/supported_laungages_command.dart index 991cd19..c5e4ea4 100644 --- a/lib/src/commands/supported_laungages_command/supported_laungages_command.dart +++ b/lib/src/commands/supported_laungages_command/supported_laungages_command.dart @@ -41,7 +41,10 @@ class SupportedLangsCommand extends Command { 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(); diff --git a/lib/src/etc/extensions.dart b/lib/src/etc/extensions.dart index f25b502..be0c02a 100644 --- a/lib/src/etc/extensions.dart +++ b/lib/src/etc/extensions.dart @@ -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, diff --git a/lib/src/etc/utils.dart b/lib/src/etc/utils.dart index 8a1884b..4455fba 100644 --- a/lib/src/etc/utils.dart +++ b/lib/src/etc/utils.dart @@ -65,7 +65,7 @@ class Utils { } String endpoint(String path) { - return 'baseUrl${path.startsWith("/") ? path : "/$path"}'; + return '$baseUrl${path.startsWith("/") ? path : "/$path"}'; } List randomLoadingFrames() {