-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
257 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
part of katana_cli.code; | ||
|
||
/// Create a base class to create a StatefulWidget. | ||
/// | ||
/// StatefulWidgetを作成するベースクラスを作成します。 | ||
class CodeStatefulCliCommand extends CliCodeCommand { | ||
/// Create a base class to create a StatefulWidget. | ||
/// | ||
/// StatefulWidgetを作成するベースクラスを作成します。 | ||
const CodeStatefulCliCommand(); | ||
|
||
@override | ||
String get name => "stateful"; | ||
|
||
@override | ||
String get prefix => "stateful"; | ||
|
||
@override | ||
String get directory => "lib/widgets"; | ||
|
||
@override | ||
String get description => | ||
"Create a StatefulWidget in `$directory/(filepath).dart`. StatefulWidgetを`$directory/(filepath).dart`に作成します。"; | ||
|
||
@override | ||
Future<void> exec(ExecContext context) async { | ||
final path = context.args.get(2, ""); | ||
if (path.isEmpty) { | ||
error( | ||
"[path] is not specified. Please enter [path] according to the following command.\r\nkatana code stateful [path]\r\n", | ||
); | ||
return; | ||
} | ||
label("Create a StatefulWidget class in `$directory/$path.dart`."); | ||
await generateDartCode("$directory/$path"); | ||
} | ||
|
||
@override | ||
String import(String path, String baseName, String className) { | ||
return """ | ||
// ignore: unused_import, unnecessary_import | ||
import 'package:flutter/material.dart'; | ||
// ignore: unused_import, unnecessary_import | ||
import 'package:masamune/masamune.dart'; | ||
// ignore: unused_import, unnecessary_import | ||
import '/main.dart'; | ||
"""; | ||
} | ||
|
||
@override | ||
String header(String path, String baseName, String className) { | ||
return """ | ||
"""; | ||
} | ||
|
||
@override | ||
String body(String path, String baseName, String className) { | ||
return """ | ||
/// StatefulWidget. | ||
@immutable | ||
class ${className}Widget extends StatefulWidget { | ||
const ${className}Widget({ | ||
super.key, | ||
// TODO: Set parameters for the widget. | ||
\${1} | ||
}); | ||
@override | ||
State<StatefulWidget> createState() => _${className}State(); | ||
} | ||
class _${className}State extends State<${className}Widget> { | ||
@override | ||
Widget build(BuildContext context) { | ||
// Describes the structure of the widget. | ||
// TODO: Implement the view. | ||
return \${2:Empty()}; | ||
} | ||
} | ||
"""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
part of katana_cli.code; | ||
|
||
/// Create a base class to create a StatelessWidget. | ||
/// | ||
/// StatelessWidgetを作成するベースクラスを作成します。 | ||
class CodeStatelessCliCommand extends CliCodeCommand { | ||
/// Create a base class to create a StatelessWidget. | ||
/// | ||
/// StatelessWidgetを作成するベースクラスを作成します。 | ||
const CodeStatelessCliCommand(); | ||
|
||
@override | ||
String get name => "stateless"; | ||
|
||
@override | ||
String get prefix => "stateless"; | ||
|
||
@override | ||
String get directory => "lib/widgets"; | ||
|
||
@override | ||
String get description => | ||
"Create a StatelessWidget in `$directory/(filepath).dart`. StatelessWidgetを`$directory/(filepath).dart`に作成します。"; | ||
|
||
@override | ||
Future<void> exec(ExecContext context) async { | ||
final path = context.args.get(2, ""); | ||
if (path.isEmpty) { | ||
error( | ||
"[path] is not specified. Please enter [path] according to the following command.\r\nkatana code stateless [path]\r\n", | ||
); | ||
return; | ||
} | ||
label("Create a StatelessWidget class in `$directory/$path.dart`."); | ||
await generateDartCode("$directory/$path"); | ||
} | ||
|
||
@override | ||
String import(String path, String baseName, String className) { | ||
return """ | ||
// ignore: unused_import, unnecessary_import | ||
import 'package:flutter/material.dart'; | ||
// ignore: unused_import, unnecessary_import | ||
import 'package:masamune/masamune.dart'; | ||
// ignore: unused_import, unnecessary_import | ||
import '/main.dart'; | ||
"""; | ||
} | ||
|
||
@override | ||
String header(String path, String baseName, String className) { | ||
return """ | ||
"""; | ||
} | ||
|
||
@override | ||
String body(String path, String baseName, String className) { | ||
return """ | ||
/// StatelessWidget. | ||
@immutable | ||
class ${className}Widget extends StatelessWidget { | ||
const ${className}Widget({ | ||
super.key, | ||
// TODO: Set parameters for the widget. | ||
\${1} | ||
}); | ||
@override | ||
Widget build(BuildContext context) { | ||
// Describes the structure of the widget. | ||
// TODO: Implement the view. | ||
return \${2:Empty()}; | ||
} | ||
} | ||
"""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
part of katana_cli.code; | ||
|
||
/// Create a base class to create a ScopedWidget. | ||
/// | ||
/// ScopedWidgetを作成するベースクラスを作成します。 | ||
class CodeWidgetCliCommand extends CliCodeCommand { | ||
/// Create a base class to create a ScopedWidget. | ||
/// | ||
/// ScopedWidgetを作成するベースクラスを作成します。 | ||
const CodeWidgetCliCommand(); | ||
|
||
@override | ||
String get name => "widget"; | ||
|
||
@override | ||
String get prefix => "widget"; | ||
|
||
@override | ||
String get directory => "lib/widgets"; | ||
|
||
@override | ||
String get description => | ||
"Create a ScopedWidget in `$directory/(filepath).dart`. ScopedWidgetを`$directory/(filepath).dart`に作成します。"; | ||
|
||
@override | ||
Future<void> exec(ExecContext context) async { | ||
final path = context.args.get(2, ""); | ||
if (path.isEmpty) { | ||
error( | ||
"[path] is not specified. Please enter [path] according to the following command.\r\nkatana code widget [path]\r\n", | ||
); | ||
return; | ||
} | ||
label("Create a ScopedWidget class in `$directory/$path.dart`."); | ||
await generateDartCode("$directory/$path"); | ||
} | ||
|
||
@override | ||
String import(String path, String baseName, String className) { | ||
return """ | ||
// ignore: unused_import, unnecessary_import | ||
import 'package:flutter/material.dart'; | ||
// ignore: unused_import, unnecessary_import | ||
import 'package:masamune/masamune.dart'; | ||
// ignore: unused_import, unnecessary_import | ||
import '/main.dart'; | ||
"""; | ||
} | ||
|
||
@override | ||
String header(String path, String baseName, String className) { | ||
return """ | ||
"""; | ||
} | ||
|
||
@override | ||
String body(String path, String baseName, String className) { | ||
return """ | ||
/// ScopedWidget. | ||
@immutable | ||
class ${className}Widget extends ScopedWidget { | ||
const ${className}Widget({ | ||
super.key, | ||
// TODO: Set parameters for the widget. | ||
\${1} | ||
}); | ||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
// Describes the process of loading | ||
// and defining variables required for the widget. | ||
// TODO: Implement the variable loading process. | ||
\${2} | ||
// Describes the structure of the widget. | ||
// TODO: Implement the view. | ||
return \${3:Empty()}; | ||
} | ||
} | ||
"""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters