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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// Export commands modules
pub mod new;
pub mod list;
pub mod preview;
pub mod transform;
pub mod config;
pub mod workspace;
pub mod component;
pub mod dependency;
pub mod unused_features;
pub mod import_fixer;
pub mod test_mode;
// Removed reference to unused module
// Re-export the Commands enum for the CLI
use clap::{Subcommand, ValueEnum};
#[derive(Debug, Clone, ValueEnum)]
pub enum ComponentType {
Client,
Server,
Shared,
Edge,
Serverless,
DataScience,
Embedded,
Library,
Minimal,
}
impl std::fmt::Display for ComponentType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match self {
ComponentType::Client => "client",
ComponentType::Server => "server",
ComponentType::Shared => "shared",
ComponentType::Edge => "edge",
ComponentType::Serverless => "serverless",
ComponentType::DataScience => "data-science",
ComponentType::Embedded => "embedded",
ComponentType::Library => "library",
ComponentType::Minimal => "minimal",
};
write!(f, "{}", s)
}
}
#[derive(Subcommand)]
pub enum Commands {
/// Create a new Rust project with interactive configuration
New {
/// Component name (optional, will prompt if not provided)
#[arg(required = false)]
name: Option<String>,
/// Component type to use (optional, will prompt if not provided)
#[arg(short, long)]
component_type: Option<ComponentType>,
/// Framework to use for client, server, or embedded components
#[arg(long)]
framework: Option<String>,
/// Cloud provider for serverless components
#[arg(long)]
provider: Option<String>,
/// Application type for edge components
#[arg(long)]
application_type: Option<String>,
/// Project type for framework-specific options (e.g., desktop, web, mobile for Dioxus)
#[arg(short, long)]
project_type: Option<String>,
/// Initialize a git repository
#[arg(short, long)]
git: bool,
/// Run cargo build after project creation
#[arg(short, long)]
build: bool,
/// Skip interactive prompts (for automated testing)
#[arg(long)]
no_interactive: bool,
},
/// Transform an existing project with interactive configuration
Transform {
/// Path to the project to transform (optional, will prompt if not provided)
#[arg(short, long)]
project: Option<String>,
/// Template to transform to (optional, will prompt if not provided)
#[arg(short, long)]
template: Option<String>,
},
/// List available component types
List,
/// Preview a component type without creating files
///
/// NOTE: This command is a work in progress and has several limitations:
/// - Not all template variables are properly replaced
/// - Some framework-specific features may not be accurately displayed
/// - File previews may not reflect actual generated content
/// - Limited support for complex template combinations
#[cfg(not(feature = "workspace_test"))]
Preview {
/// Component type to preview (optional, will prompt if not provided)
#[arg(short, long)]
component_type: Option<ComponentType>,
/// Framework to use for client, server, or embedded components
#[arg(long)]
framework: Option<String>,
/// Cloud provider for serverless components
#[arg(long)]
provider: Option<String>,
/// Application type for edge components
#[arg(long)]
application_type: Option<String>,
},
/// Manage project components (add/remove/list) with consistent component types
#[cfg(not(feature = "workspace_test"))]
Component {
/// Action to perform: add, remove, or list
#[arg(short, long)]
action: Option<String>,
/// Component type: client, server, ferrisup_common, edge, data-science, embedded
#[arg(short, long)]
component_type: Option<ComponentType>,
/// Path to the project (optional, will use current directory if not provided)
#[arg(short, long)]
project: Option<String>,
},
/// Manage configurations (export/import)
#[cfg(not(feature = "workspace_test"))]
Config {
/// Export the current configuration to a file
#[arg(short, long)]
export: bool,
/// Import a configuration from a file
#[arg(short, long)]
import: Option<String>,
/// Path to export/import configuration (optional)
#[arg(short, long)]
path: Option<String>,
},
/// Manage Cargo workspaces
Workspace {
/// Action to perform: init, add, remove, list, or optimize
#[arg(short, long)]
action: Option<String>,
/// Path to the workspace (optional, will use current directory if not provided)
#[arg(short, long)]
path: Option<String>,
},
/// Manage project dependencies
#[cfg(not(feature = "workspace_test"))]
Dependency(dependency::DependencyArgs),
/// Find unused features in Cargo dependencies
#[cfg(not(feature = "workspace_test"))]
UnusedFeatures {
/// Path to the project (optional, will use current directory if not provided)
#[arg(short, long)]
path: Option<String>,
},
}