Skip to content

Commit

Permalink
update cli
Browse files Browse the repository at this point in the history
  • Loading branch information
iyifr committed Dec 8, 2024
1 parent c8ed0b4 commit 8b73290
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
![og](/lib/assets/H4-banne.png)
A sleek and powerful HTTP framework that makes Dart API development a breeze.


**A sleek and powerful HTTP framework that makes Dart API development a breeze**

Inspired by [unjs H3](https://h3.unjs.io).

**This is a new project under active development**, production use is not advised.
Expand Down Expand Up @@ -108,8 +109,8 @@ The client recieves this json payload -

```json
{
"status": 400,
"message": "Womp Womp"
"status": 400,
"message": "Womp Womp"
}
```

Expand Down
17 changes: 8 additions & 9 deletions bin/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'dart:async';
import 'dart:io';
import 'package:console/console.dart';
import 'dart:convert';
import 'package:path/path.dart' as path;

void main(List<String> arguments) async {
if (!await _isH4Installed()) {
Expand Down Expand Up @@ -70,8 +69,6 @@ Future<void> _createAppFiles(String appName,
Console.setBold(true);
Console.write('\n\nInstalling necessary dependencies...\n'.toUpperCase());
File mainFile;
File defaultFile =
File('lib/${path.basename(Directory.current.path)}.dart');

if (inCurrentDir) {
Process.runSync('dart', ['pub', 'add', 'h4'],
Expand All @@ -80,22 +77,24 @@ Future<void> _createAppFiles(String appName,
Console.setBlink(false);
} else {
mainFile = File('$appName/lib/index.dart');
defaultFile = File('$appName/lib/$appName.dart');
await runProcessInDirectory(appName, ['dart', 'pub', 'add', 'h4'])
.then((value) => Console.setBlink(false));
}

Console.setBold(false);
await _writeMainFile(mainFile);

if (await defaultFile.exists()) {
await defaultFile.delete();
if (File('$appName/lib/${appName.replaceAll('-', '_')}.dart')
.existsSync()) {
await File('$appName/lib/${appName.replaceAll('-', '_')}.dart').delete();
} else {
Console.write('---Failed to clear appName file');
}

Console.setBold(true);
Console.write('\nH4 initialized successfully'.toUpperCase());
} catch (e) {
Console.write('\nFailed to create H4 app. Error: $e');
} catch (e, stacktrace) {
Console.write('\nFailed to create H4 app. Error: $e /n $stacktrace');
return;
}
}
Expand Down Expand Up @@ -149,7 +148,7 @@ Future<String> _promptAppName() async {
'\nEnter a name for your app (or press Enter to skip and set default): ');
final name = stdin.readLineSync(encoding: utf8) ?? '';
Console.resetAll();
return name.isNotEmpty ? name : 'my-app';
return name.isNotEmpty ? name : 'h4-server';
}

Future<void> _writeMainFile(File mainFile) async {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: h4
description: A minimal framework for building elegant server applications.
version: 0.3.1
version: 0.3.2
repository: https://github.com/iyifr/h4

environment:
Expand Down

0 comments on commit 8b73290

Please sign in to comment.