Skip to content

Commit

Permalink
[ Edit ] edited the prompt logger to confirm, corrected typo
Browse files Browse the repository at this point in the history
  • Loading branch information
anasfik committed Sep 24, 2023
1 parent f64d960 commit cbf257f
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 92 deletions.
72 changes: 1 addition & 71 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1 @@
## langsync

![coverage][coverage_badge]
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
[![License: MIT][license_badge]][license_link]

Generated by the [Very Good CLI][very_good_cli_link] 🤖

A Very Good Project created by Very Good CLI..

---

## Getting Started 🚀

If the CLI application is available on [pub](https://pub.dev), activate globally via:

```sh
dart pub global activate langsync
```

Or locally via:

```sh
dart pub global activate --source=path <path to this package>
```

## Usage

```sh
# Sample command
$ langsync sample

# Sample command option
$ langsync sample --cyan

# Show CLI version
$ langsync --version

# Show usage help
$ langsync --help
```

## Running Tests with coverage 🧪

To run all unit tests use the following command:

```sh
$ dart pub global activate coverage 1.2.0
$ dart test --coverage=coverage
$ dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info
```

To view the generated coverage report you can use [lcov](https://github.com/linux-test-project/lcov)
.

```sh
# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/

# Open Coverage Report
$ open coverage/index.html
```

---

[coverage_badge]: coverage_badge.svg
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
[license_link]: https://opensource.org/licenses/MIT
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis
[very_good_cli_link]: https://github.com/VeryGoodOpenSource/very_good_cli
// TODO: add confirmation to logout command.
Binary file added bin/langsync.exe
Binary file not shown.
3 changes: 3 additions & 0 deletions example/locales/ar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"مرحبًا": "مرحبًا يا صديقي"
}
3 changes: 3 additions & 0 deletions example/locales/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"hallo": "hallo mein Freund"
}
3 changes: 3 additions & 0 deletions example/locales/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"hello": "bonjour mon ami"
}
2 changes: 1 addition & 1 deletion langsync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ langsync:

output: './example/locales'

target: [ge, zh, es]
target: [fr, de, ar, de, zh]
10 changes: 10 additions & 0 deletions lib/src/commands/account_command/sub_commands/logout_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ class LogoutCommand extends Command<int> {

return ExitCode.success.code;
} else {
final confirm = await logger.confirm(
'Are you sure you want to logout from the current account?',
);

if (!confirm) {
logger.info('Logout aborted.');

return ExitCode.success.code;
}

final logoutProgress =
logger.customProgress('Logging out from the account..');

Expand Down
15 changes: 6 additions & 9 deletions lib/src/commands/config_command/sub_commands/create_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,16 @@ class ConfigCreateCommand extends Command<int> {
}

Future<int> _requestToOverwrite(File file) async {
final userAnswer = logger.prompt('Do you want to overwrite it? (Y/n)');
final confirmOverwrite = logger.confirm('Do you want to overwrite it?');

final toL = userAnswer.toLowerCase();

if (utils.isConsideredTrue(toL)) {
if (confirmOverwrite) {
final deleteLogger =
logger.customProgress('Deleting the existant langsync.yaml file');

await file.delete();

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

return run();
} else {
Expand Down Expand Up @@ -84,12 +82,11 @@ class ConfigCreateCommand extends Command<int> {
final outputDirectory = Directory(outputDir);

if (!outputDirectory.existsSync()) {
final createDirAnswer = logger.prompt(
final confirmOverwrite = logger.confirm(
'''The output directory at $outputDir does not exist, do you want to create it? (Y/n)''',
);
final toL = createDirAnswer.toLowerCase();

if (utils.isConsideredTrue(toL)) {
if (confirmOverwrite) {
final createDirProgress =
logger.customProgress('Creating the output directory');

Expand Down Expand Up @@ -143,7 +140,7 @@ class ConfigCreateCommand extends Command<int> {
await YamlController.iterateAndWriteToConfigFile(config);

creationProgress.complete(
'langsync.yaml file created & updated with your config succesfully.',
'langsync.yaml file created & updated with your config successfully.',
);

return ExitCode.success.code;
Expand Down
6 changes: 3 additions & 3 deletions lib/src/commands/start_command/start_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class StartCommand extends Command<int> {
);

savingSourceFileProgress
.complete('Your source file has been saved succesfully.');
.complete('Your source file has been saved successfully.');

logger
// ..info("\n")
Expand Down Expand Up @@ -176,9 +176,9 @@ class StartCommand extends Command<int> {
.convert(current.jsonFormattedResponse),
);

progress.complete('file $fileName is created succesfully, ${file.path}');
progress.complete('file $fileName is created successfully, ${file.path}');
}

logger.success('All files are created succesfully.');
logger.success('All files are created successfully.');
}
}
16 changes: 8 additions & 8 deletions lib/src/etc/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Utils {
}

String endpoint(String path) {
return 'http://192.168.1.103:5559${path.startsWith("/") ? path : "/$path"}';
return 'http://192.168.0.3:5559${path.startsWith("/") ? path : "/$path"}';
}

List<String> randomLoadingFrames() {
Expand Down Expand Up @@ -91,11 +91,11 @@ class Utils {
});
}

bool isConsideredTrue(String answer) {
return answer == 'y' ||
answer == 'yes' ||
answer == 'yep' ||
answer == 'yeah' ||
answer == 'true';
}
// bool isConsideredTrue(String answer) {
// return answer == 'y' ||
// answer == 'yes' ||
// answer == 'yep' ||
// answer == 'yeah' ||
// answer == 'true';
// }
}

0 comments on commit cbf257f

Please sign in to comment.