-
Notifications
You must be signed in to change notification settings - Fork 0
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
11 changed files
with
502 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ edition = "2021" | |
|
||
[dependencies] | ||
clap = { version = "4.3.19", features = ["derive"] } | ||
boilerplate = "1.0.0" |
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 |
---|---|---|
@@ -1,22 +1,84 @@ | ||
use std::fs; | ||
use clap::Parser; | ||
use boilerplate; | ||
use boilerplate::Boilerplate; | ||
|
||
#[derive(Parser, Debug)] | ||
#[command(author, version, about, long_about = None)] | ||
struct Args { | ||
/// Name of the project | ||
#[arg(short, long)] | ||
name: String, | ||
#[arg(short, long, default_value = "test")] | ||
plane: String, | ||
#[arg(short, long, default_value_t = 9001)] | ||
/// Port of the Swim application | ||
#[arg(long, default_value_t = 9001)] | ||
port: u16, | ||
#[arg(short, long, default_value = "4.0.1")] | ||
version: String, | ||
/// Version of the Swim application | ||
#[arg(long, default_value = "4.0.1")] | ||
swim_version: String, | ||
} | ||
|
||
#[derive(Boilerplate)] | ||
#[boilerplate(filename = "settings.gradle")] | ||
struct SettingsGradle<'a> { | ||
name: &'a String, | ||
} | ||
|
||
#[derive(Boilerplate)] | ||
#[boilerplate(filename = "build.gradle")] | ||
struct BuildGradle<'a, 'b> { | ||
name: &'a String, | ||
swim_version: &'b String, | ||
} | ||
|
||
#[derive(Boilerplate)] | ||
#[boilerplate(filename = "MainPlane.java")] | ||
struct MainPlaneJava<'a> { | ||
name: &'a String, | ||
} | ||
|
||
#[derive(Boilerplate)] | ||
#[boilerplate(filename = "module-info.java")] | ||
struct ModuleInfoJava<'a> { | ||
name: &'a String, | ||
} | ||
|
||
#[derive(Boilerplate)] | ||
#[boilerplate(filename = "server.recon")] | ||
struct ServerRecon<'a> { | ||
name: &'a String, | ||
port: u16, | ||
} | ||
|
||
#[derive(Boilerplate)] | ||
#[boilerplate(filename = "gradlew")] | ||
struct Gradlew; | ||
|
||
#[derive(Boilerplate)] | ||
#[boilerplate(filename = "gradlew.bat")] | ||
struct GradlewBat; | ||
|
||
|
||
#[derive(Boilerplate)] | ||
#[boilerplate(filename = "test/.gitignore")] | ||
struct Gitignore; | ||
|
||
fn main() { | ||
let args = Args::parse(); | ||
|
||
println!("Hello {}!", args.name) | ||
println!("Name: {}", args.name); | ||
println!("Port: {}", args.port); | ||
println!("Swim version: {}", args.swim_version); | ||
|
||
fs::create_dir(&args.name).unwrap(); | ||
fs::create_dir_all(format!("{0}/src/main/java/{0}", args.name)).unwrap(); | ||
fs::create_dir_all(format!("{0}/src/main/resources", args.name)).unwrap(); | ||
|
||
fs::write(format!("{0}/{SETTINGS_GRADLE}", args.name), SettingsGradle { name: &args.name }.to_string()).expect("Unable to write file"); | ||
fs::write(format!("{0}/build.gradle", args.name), BuildGradle { name: &args.name, swim_version: &args.swim_version }.to_string()).expect("Unable to write file"); | ||
fs::write(format!("{0}/.gitignore", args.name), Gitignore.to_string()).expect("Unable to write file"); | ||
fs::write(format!("{0}/gradlew", args.name), Gradlew.to_string()).expect("Unable to write file"); | ||
fs::write(format!("{0}/gradlew.bat", args.name), GradlewBat.to_string()).expect("Unable to write file"); | ||
|
||
fs::write(format!("{0}/src/main/java/{0}/MainPlane.java", args.name), MainPlaneJava { name: &args.name }.to_string()).expect("Unable to write file"); | ||
fs::write(format!("{0}/src/main/java/module-info.java", args.name), ModuleInfoJava { name: &args.name }.to_string()).expect("Unable to write file"); | ||
fs::write(format!("{0}/src/main/resources/server.recon", args.name), ServerRecon { name: &args.name, port: args.port }.to_string()).expect("Unable to write file"); | ||
} |
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,4 @@ | ||
.idea | ||
.gradle | ||
gradle | ||
build |
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,16 @@ | ||
package {{self.name}}; | ||
|
||
import swim.api.plane.AbstractPlane; | ||
import swim.kernel.Kernel; | ||
import swim.server.ServerLoader; | ||
|
||
public class MainPlane extends AbstractPlane { | ||
|
||
public static void main(String[] args) { | ||
final Kernel kernel = ServerLoader.loadServer(); | ||
System.out.println("Starting server..."); | ||
kernel.start(); | ||
System.out.println("Running server..."); | ||
kernel.run(); | ||
} | ||
} |
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,13 @@ | ||
apply plugin: 'application' | ||
|
||
version = '0.0.1' | ||
mainClassName = '{{self.name}}.MainPlane' | ||
ext.moduleName = '{{self.name}}' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation group: 'org.swimos', name: 'swim-server', version: '{{self.swim_version}}' | ||
} |
Oops, something went wrong.