mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 15:54:35 +01:00
new: server tab process
This commit is contained in:
@@ -6,6 +6,7 @@ enum ServerTabMenuType {
|
||||
snippet,
|
||||
pkg,
|
||||
docker,
|
||||
process,
|
||||
edit;
|
||||
|
||||
IconData get icon {
|
||||
@@ -20,6 +21,8 @@ enum ServerTabMenuType {
|
||||
return Icons.view_agenda;
|
||||
case ServerTabMenuType.edit:
|
||||
return Icons.edit;
|
||||
case ServerTabMenuType.process:
|
||||
return Icons.list_alt_outlined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +38,8 @@ enum ServerTabMenuType {
|
||||
return 'Docker';
|
||||
case ServerTabMenuType.edit:
|
||||
return s.edit;
|
||||
case ServerTabMenuType.process:
|
||||
return s.process;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
41
lib/data/model/app/shell_func.dart
Normal file
41
lib/data/model/app/shell_func.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
class AppShellFunc {
|
||||
final String name;
|
||||
final String cmd;
|
||||
final String flag;
|
||||
|
||||
const AppShellFunc(this.name, this.cmd, this.flag);
|
||||
}
|
||||
|
||||
typedef AppShellFuncs = List<AppShellFunc>;
|
||||
|
||||
extension AppShellFuncsExt on AppShellFuncs {
|
||||
String get generate {
|
||||
final sb = StringBuffer();
|
||||
// Write each func
|
||||
for (final func in this) {
|
||||
sb.write('''
|
||||
${func.name}() {
|
||||
${func.cmd}
|
||||
}
|
||||
|
||||
''');
|
||||
}
|
||||
|
||||
// Write switch case
|
||||
sb.write('case \$1 in\n');
|
||||
for (final func in this) {
|
||||
sb.write('''
|
||||
'-${func.flag}')
|
||||
${func.name}
|
||||
;;
|
||||
''');
|
||||
}
|
||||
sb.write('''
|
||||
*)
|
||||
echo "Invalid argument \$1"
|
||||
;;
|
||||
esac
|
||||
''');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user