Skip to content

Commit 18b1f5c

Browse files
committed
feat: add project, template, workspace, and machine commands
- Add chrono crate for date/time handling. - Add a `run` command alias in the script. - Update git cliff usage in release script to handle changes since the latest tag. - Change the short flag for the "hosty" argument in the machine command. - Add `connect` and `remove` subcommands to the machine command. - Include functionality for adding, showing information about, and listing projects. - Introduce options for adding project details like path, template, description, language, framework, and tags. - Add a raw output flag to the project list command. - Modify the alias for the description argument in the template add command. - Add language, framework, and tags arguments to the template add command. - Implement list, info, and apply subcommands for the template command. - Add functionality for adding and listing workspaces. - Introduce options for adding workspace details like path, description, and associated projects. - Add a raw output flag to the workspace list command. - Enhance the component subcommand for workspaces to support add, remove, and list actions, including options for component type and path. - Implement handlers for the new machine subcommands (connect and remove). - Create new modules and handlers for project add, info, and list commands. - Update project module to include structs and methods for managing projects, including adding, finding, and formatting project data for display. - Create new
1 parent ef707f7 commit 18b1f5c

25 files changed

Lines changed: 1411 additions & 28 deletions

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ regex = "1.10.5"
2626
tabled = { version = "0.15.0"}
2727
russh = "0.49.2"
2828
skim = "0.16.0"
29+
chrono = { version = "0.4", features = ["serde"] }

run.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/bin/bash
22

3-
43
# @cmd build cargo project
54
# @alias b
65
build() {
76
cargo build --release
87
}
98

9+
run() {
10+
./target/release/dp
11+
}
1012

1113
# @cmd mark as releaser
12-
# @alias r
1314
# @arg type![patch|minor|major] Release type
1415
release() {
1516
# echo "release $1"
@@ -31,9 +32,17 @@ release() {
3132
;;
3233
esac
3334
version="$MAJOR.$MINOR.$PATCH"
35+
LATEST_TAG=$(git tag --list --sort=-version:refname | head -n 1)
36+
if [ -n "$LATEST_TAG" ]; then
37+
# Not the first release - get changes since last tag
38+
changelog=$(git cliff $LATEST_TAG..HEAD --strip all)
39+
git cliff --tag $version $LATEST_TAG..HEAD --prepend CHANGELOG.md
40+
else
41+
# First release - get all changes
42+
changelog=$(git cliff --unreleased --strip all)
43+
git cliff --tag $version --unreleased --prepend CHANGELOG.md
44+
fi
3445
sed -i "s/^version = \".*\"/version = \"$version\"/" Cargo.toml
35-
git cliff --tag $version > CHANGELOG.md
36-
changelog=$(git cliff --unreleased --strip all)
3746
git add -A && git commit -m "chore(release): prepare for $version"
3847
echo "$changelog"
3948
git tag -a $version -m "$version" -m "$changelog"

src/arguments/machine.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn cmd() -> Command {
9292
.arg(
9393
Arg::new("hosty")
9494
.help("Hostname ready mode")
95-
.short('h')
95+
.short('H')
9696
.long("hosty")
9797
.action(ArgAction::SetTrue),
9898
),
@@ -107,4 +107,42 @@ pub fn cmd() -> Command {
107107
.value_name("MACHINE_NAME"),
108108
),
109109
)
110+
.subcommand(
111+
Command::new("connect")
112+
.about("Connect to a machine via SSH")
113+
.aliases(["c", "ssh"])
114+
.arg_required_else_help(true)
115+
.arg(
116+
Arg::new("machine_name")
117+
.help("Name of the machine to connect to")
118+
.required(true)
119+
.value_name("MACHINE_NAME"),
120+
)
121+
.arg(
122+
Arg::new("interface")
123+
.short('i')
124+
.long("interface")
125+
.help("Interface to use for connection")
126+
.value_name("INTERFACE")
127+
)
128+
.arg(
129+
Arg::new("command")
130+
.short('c')
131+
.long("command")
132+
.help("Command to execute on remote machine")
133+
.value_name("COMMAND")
134+
)
135+
)
136+
.subcommand(
137+
Command::new("remove")
138+
.about("Remove a machine")
139+
.aliases(["r", "rm", "delete"])
140+
.arg_required_else_help(true)
141+
.arg(
142+
Arg::new("machine_name")
143+
.help("Name of the machine to remove")
144+
.required(true)
145+
.value_name("MACHINE_NAME"),
146+
)
147+
)
110148
}

src/arguments/project.rs

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use clap::{Command, Arg};
1+
use clap::{Command, Arg, ArgAction};
22

33
pub fn cmd() -> Command {
44
Command::new("project")
@@ -14,6 +14,60 @@ pub fn cmd() -> Command {
1414
.value_name("NAMESPACE")
1515
.default_value("default")
1616
)
17+
.subcommand(
18+
Command::new("add")
19+
.about("Add a new project")
20+
.aliases(["a", "new", "create"])
21+
.arg_required_else_help(true)
22+
.arg(
23+
Arg::new("name")
24+
.help("Name of the project")
25+
.required(true)
26+
.value_name("PROJECT_NAME")
27+
)
28+
.arg(
29+
Arg::new("path")
30+
.short('p')
31+
.long("path")
32+
.help("Path to the project directory")
33+
.value_name("PROJECT_PATH")
34+
)
35+
.arg(
36+
Arg::new("template")
37+
.short('t')
38+
.long("template")
39+
.help("Template to use for the project")
40+
.value_name("TEMPLATE_NAME")
41+
)
42+
.arg(
43+
Arg::new("description")
44+
.short('d')
45+
.long("description")
46+
.help("Description of the project")
47+
.value_name("DESCRIPTION")
48+
)
49+
.arg(
50+
Arg::new("language")
51+
.short('l')
52+
.long("language")
53+
.help("Primary programming language")
54+
.value_name("LANGUAGE")
55+
)
56+
.arg(
57+
Arg::new("framework")
58+
.short('f')
59+
.long("framework")
60+
.help("Framework used in the project")
61+
.value_name("FRAMEWORK")
62+
)
63+
.arg(
64+
Arg::new("tags")
65+
.long("tags")
66+
.help("Tags for the project")
67+
.value_name("TAG")
68+
.action(ArgAction::Append)
69+
)
70+
)
1771
.subcommand(
1872
Command::new("info")
1973
.about("Print information about a project")
@@ -30,5 +84,12 @@ pub fn cmd() -> Command {
3084
Command::new("list")
3185
.about("List all projects in the workspace")
3286
.aliases(["l", "ls"])
87+
.arg(
88+
Arg::new("raw")
89+
.help("Raw mode")
90+
.short('r')
91+
.long("raw")
92+
.action(ArgAction::SetTrue)
93+
)
3394
)
3495
}

src/arguments/template.rs

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use clap::{Command, Arg};
1+
use clap::{Command, Arg, ArgAction};
22

33
pub fn cmd() -> Command {
44
Command::new("template")
@@ -21,7 +21,7 @@ pub fn cmd() -> Command {
2121
Arg::new("description")
2222
.short('d')
2323
.long("description")
24-
.aliases(&["description", "desc"])
24+
.aliases(&["desc"])
2525
.help("Description of the template")
2626
.required(true)
2727
.value_name("DESCRIPTION")
@@ -30,10 +30,79 @@ pub fn cmd() -> Command {
3030
Arg::new("path")
3131
.short('p')
3232
.long("path")
33-
.aliases(&["path", "p"])
3433
.help("Path to the template")
3534
.required(true)
3635
.value_name("TEMPLATE_PATH")
3736
)
37+
.arg(
38+
Arg::new("language")
39+
.short('l')
40+
.long("language")
41+
.help("Primary programming language")
42+
.value_name("LANGUAGE")
43+
)
44+
.arg(
45+
Arg::new("framework")
46+
.short('f')
47+
.long("framework")
48+
.help("Framework used in the template")
49+
.value_name("FRAMEWORK")
50+
)
51+
.arg(
52+
Arg::new("tags")
53+
.long("tags")
54+
.help("Tags for the template")
55+
.value_name("TAG")
56+
.action(ArgAction::Append)
57+
)
58+
)
59+
.subcommand(
60+
Command::new("list")
61+
.about("List all templates")
62+
.aliases(["l", "ls"])
63+
.arg(
64+
Arg::new("raw")
65+
.help("Raw mode")
66+
.short('r')
67+
.long("raw")
68+
.action(ArgAction::SetTrue)
69+
)
70+
)
71+
.subcommand(
72+
Command::new("info")
73+
.about("Show template information")
74+
.aliases(["i", "show"])
75+
.arg_required_else_help(true)
76+
.arg(
77+
Arg::new("template_name")
78+
.help("Name of the template")
79+
.required(true)
80+
.value_name("TEMPLATE_NAME")
81+
)
82+
)
83+
.subcommand(
84+
Command::new("apply")
85+
.about("Apply a template to create a new project")
86+
.aliases(["use", "create"])
87+
.arg_required_else_help(true)
88+
.arg(
89+
Arg::new("template_name")
90+
.help("Name of the template to apply")
91+
.required(true)
92+
.value_name("TEMPLATE_NAME")
93+
)
94+
.arg(
95+
Arg::new("target_path")
96+
.help("Target path for the new project")
97+
.required(true)
98+
.value_name("TARGET_PATH")
99+
)
100+
.arg(
101+
Arg::new("project_name")
102+
.short('n')
103+
.long("name")
104+
.help("Name for the new project (replaces placeholders)")
105+
.value_name("PROJECT_NAME")
106+
)
38107
)
39108
}

src/arguments/workspace.rs

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,56 @@
1-
use clap::{Command, Arg};
1+
use clap::{Command, Arg, ArgAction};
22

33
pub fn cmd() -> Command {
44
Command::new("workspace")
55
.about("Workspace related commands")
66
.aliases(&["w", "workspaces", "ws"])
77
.subcommand_required(true)
88
.arg_required_else_help(true)
9+
.subcommand(
10+
Command::new("add")
11+
.about("Add a new workspace")
12+
.aliases(["a", "new", "create"])
13+
.arg_required_else_help(true)
14+
.arg(
15+
Arg::new("name")
16+
.help("Name of the workspace")
17+
.required(true)
18+
.value_name("WORKSPACE_NAME")
19+
)
20+
.arg(
21+
Arg::new("path")
22+
.short('p')
23+
.long("path")
24+
.help("Path to the workspace directory")
25+
.value_name("WORKSPACE_PATH")
26+
)
27+
.arg(
28+
Arg::new("description")
29+
.short('d')
30+
.long("description")
31+
.help("Description of the workspace")
32+
.value_name("DESCRIPTION")
33+
)
34+
.arg(
35+
Arg::new("projects")
36+
.long("projects")
37+
.help("Project names to associate with this workspace")
38+
.value_name("PROJECT")
39+
.action(ArgAction::Append)
40+
)
41+
)
42+
.subcommand(
43+
Command::new("list")
44+
.about("List all workspaces")
45+
.aliases(["l", "ls"])
46+
.arg(
47+
Arg::new("raw")
48+
.help("Raw mode")
49+
.short('r')
50+
.long("raw")
51+
.action(ArgAction::SetTrue)
52+
)
53+
)
954
.subcommand(
1055
Command::new("info")
1156
.about("Print information about a workspace")
@@ -20,14 +65,40 @@ pub fn cmd() -> Command {
2065
)
2166
.subcommand(
2267
Command::new("component")
23-
.about("add or remove components from a workspace")
68+
.about("Add or remove components from a workspace")
2469
.aliases(["c", "components", "comp"])
2570
.arg_required_else_help(true)
2671
.arg(
2772
Arg::new("workspace_name")
28-
.help("Name of the workspace to add or remove components")
73+
.help("Name of the workspace to manage components")
2974
.required(true)
3075
.value_name("WORKSPACE_NAME")
3176
)
77+
.arg(
78+
Arg::new("action")
79+
.help("Action to perform (add, remove, list)")
80+
.value_name("ACTION")
81+
.default_value("list")
82+
)
83+
.arg(
84+
Arg::new("component_name")
85+
.help("Name of the component")
86+
.value_name("COMPONENT_NAME")
87+
)
88+
.arg(
89+
Arg::new("component_type")
90+
.short('t')
91+
.long("type")
92+
.help("Type of component (project, tool, config)")
93+
.value_name("TYPE")
94+
.default_value("project")
95+
)
96+
.arg(
97+
Arg::new("component_path")
98+
.short('p')
99+
.long("path")
100+
.help("Path to the component")
101+
.value_name("PATH")
102+
)
32103
)
33104
}

0 commit comments

Comments
 (0)