Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F5463596
D2763.id7012.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D2763.id7012.diff
View Options
diff --git a/.arcconfig b/.arcconfig
new file mode 100644
--- /dev/null
+++ b/.arcconfig
@@ -0,0 +1,4 @@
+{
+ "phabricator.uri": "https://devcentral.nasqueron.org/",
+ "repository.callsign": "NPUSH"
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/target
+Cargo.lock
\ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "notification-push"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+clap = { version = "4.1.1", features = ["derive"] }
+serde = { version = "1.0.152", features = ["derive"] }
+serde_json = "1.0.91"
diff --git a/src/args.rs b/src/args.rs
new file mode 100644
--- /dev/null
+++ b/src/args.rs
@@ -0,0 +1,24 @@
+use clap::Parser;
+
+#[derive(Debug, Parser)]
+#[clap(author, version, about)]
+pub struct ValidateArgs {
+ /// The notification's source service (e.g. GitHub, Phabricator, Jenkins)
+ pub services: String,
+
+ /// The notification's target project (e.g. Wikimedia, Nasqueron, Wolfplex)
+ pub project: String,
+
+ /// The notification's target group (e.g. Tasacora, Operations)
+ pub group: String,
+
+ /// The notification's type (e.g. "commits", "task")
+ pub info_type: String,
+
+ /// The notification's text
+ pub text: Option<String>,
+
+ /// The notification's URL, to be used as the main link for widgets
+ pub link: Option<String>,
+
+}
\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,44 @@
+mod args;
+
+use args::ValidateArgs;
+use clap::Parser;
+use serde::{Serialize};
+// use serde_json::Result;
+
+#[derive(Serialize)]
+struct Notification {
+ services: String,
+ project: String,
+ group: String,
+ info_type: String,
+ text: String,
+ link: String,
+}
+
+fn main() {
+
+ // ====================================
+ // Parse arguments (clap)
+ // ====================================
+ let _args:ValidateArgs = ValidateArgs::parse();
+
+ // ====================================
+ // Arguments to JSON (serde)
+ // ====================================
+ let populated_notification = Notification {
+ services: _args.services,
+ project: _args.project,
+ group: _args.group,
+ info_type: _args.info_type,
+ text: _args.text.unwrap_or("".to_string()),
+ link: _args.link.unwrap_or("".to_string()),
+ };
+
+ // ====================================
+ // Send JSON as HTTP request (reqwest)
+ // ====================================
+ let serialized = serde_json::to_string(&populated_notification).unwrap();
+ println!("serialized = {}", serialized);
+}
+
+
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 13, 03:15 (13 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2480647
Default Alt Text
D2763.id7012.diff (2 KB)
Attached To
Mode
D2763: 1st commit
Attached
Detach File
Event Timeline
Log In to Comment