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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use std::path::PathBuf;
use clap::{Parser, Subcommand};
#[derive(Debug, Subcommand)]
pub enum Command {
/// Create a new factorio-rs project in the current directory.
Init(InitArgs),
/// Transpile Rust sources to a loadable Factorio mod directory.
Build(BuildArgs),
/// Build and package the mod into a Factorio-ready zip archive.
Package(PackageArgs),
/// Build and copy the mod into the Factorio mods directory.
Install(InstallArgs),
/// Open Factorio if it is installed on this system.
Open,
}
#[derive(Debug, Parser)]
#[command(
name = "factorio-rs",
about = "Transpile Rust into Lua for Factorio mods",
version
)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Parser)]
pub struct InitArgs {
/// Name of the generated Cargo package.
#[arg(long, value_name = "NAME")]
pub name: Option<String>,
/// Path to the project directory or `Factorio.toml` file.
#[arg(long, value_name = "PATH")]
pub manifest_path: Option<PathBuf>,
}
#[derive(Debug, Parser)]
pub struct BuildArgs {
/// Path to the project directory or `Factorio.toml` file.
#[arg(long, value_name = "PATH")]
pub manifest_path: Option<PathBuf>,
/// Transpile profile from `Factorio.toml` (`debug`, `release`, or custom).
///
/// Defaults to `debug`.
#[arg(long, value_name = "NAME", default_value = "debug")]
pub profile: String,
/// Override the profile's debug comment level in generated Lua.
#[arg(long, value_name = "LEVEL")]
pub debug_level: Option<u8>,
/// Also create a `{name}_{version}.zip` archive after building.
#[arg(long)]
pub package: bool,
}
#[derive(Debug, Parser)]
pub struct PackageArgs {
/// Path to the project directory or `Factorio.toml` file.
#[arg(long, value_name = "PATH")]
pub manifest_path: Option<PathBuf>,
/// Transpile profile from `Factorio.toml`.
///
/// Defaults to `release`.
#[arg(long, value_name = "NAME", default_value = "release")]
pub profile: String,
/// Override the profile's debug comment level in generated Lua.
#[arg(long, value_name = "LEVEL")]
pub debug_level: Option<u8>,
}
#[derive(Debug, Parser)]
pub struct InstallArgs {
/// Path to the project directory or `Factorio.toml` file.
#[arg(long, value_name = "PATH")]
pub manifest_path: Option<PathBuf>,
/// Transpile profile from `Factorio.toml`.
///
/// Defaults to `debug`.
#[arg(long, value_name = "NAME", default_value = "debug")]
pub profile: String,
/// Override the profile's debug comment level in generated Lua.
#[arg(long, value_name = "LEVEL")]
pub debug_level: Option<u8>,
/// Open Factorio after installing the mod.
#[arg(long)]
pub open: bool,
}