~starkingdoms/starkingdoms

ref: d2b8956323d8e82903824637cdcfb2f978dd94e9 starkingdoms/crates/xtask/src/unified.rs -rw-r--r-- 1.8 KiB
d2b89563 — core chore: please thy lord clippy 15 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use std::env::set_current_dir;
use crate::Task;
use crate::util::{cargo, workspace_dir};

#[derive(Default)]
pub struct RunServerNative;
impl Task for RunServerNative {
    fn name(&self) -> &'static str {
        "unified:server"
    }
    fn help(&self) -> &'static str {
        "Run the server (native)"
    }

    fn run(&self, args: Vec<String>) {
        let args = if args.is_empty() {
            "-b [::]:5151 -r 60 -c 10".to_string()
        } else {
            args.join(" ")
        };
        set_current_dir(workspace_dir().join("crates/unified/")).unwrap();
        cargo(format!("run -F native -F server --package starkingdoms -- server {args}"));
    }
}

#[derive(Default)]
pub struct RunListenServerNative;
impl Task for RunListenServerNative {
    fn name(&self) -> &'static str {
        "unified:listenserver"
    }
    fn help(&self) -> &'static str {
        "Run the server and client (native)"
    }

    fn run(&self, args: Vec<String>) {
        let args = if args.is_empty() {
            "-b [::]:5151 -r 60 -c 10 --with-client".to_string()
        } else {
            args.join(" ")
        };
        set_current_dir(workspace_dir().join("crates/unified/")).unwrap();
        cargo(format!("run -F native -F server -F client --package starkingdoms -- server {args}"));
    }
}

#[derive(Default)]
pub struct RunClientNative;
impl Task for RunClientNative {
    fn name(&self) -> &'static str {
        "unified:client"
    }
    fn help(&self) -> &'static str {
        "Run the client (native)"
    }

    fn run(&self, args: Vec<String>) {
        let args = if args.is_empty() {
            "-s [::]:5151".to_string()
        } else {
            args.join(" ")
        };
        set_current_dir(workspace_dir().join("crates/unified/")).unwrap();
        cargo(format!("run -F native -F client --package starkingdoms -- client {args}"));
    }
}