6 files changed
+299
-28
Cargo.lock
+239
-18
@@ -23,6 +23,15 @@ dependencies = [
23
"memchr",
24
]
25
26
+[[package]]
27
+name = "android_system_properties"
28
+version = "0.1.5"
29
+source = "registry+https://github.com/rust-lang/crates.io-index"
30
+checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
31
+dependencies = [
32
+ "libc",
33
+]
34
+
35
[[package]]
36
name = "anyhow"
37
version = "1.0.69"
@@ -117,6 +126,22 @@ version = "1.0.0"
126
source = "registry+https://github.com/rust-lang/crates.io-index"
127
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
128
129
+[[package]]
130
+name = "chrono"
131
+version = "0.4.24"
132
+source = "registry+https://github.com/rust-lang/crates.io-index"
133
+checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b"
134
+dependencies = [
135
+ "iana-time-zone",
136
+ "js-sys",
137
+ "num-integer",
138
+ "num-traits",
139
+ "serde",
140
+ "time 0.1.45",
141
+ "wasm-bindgen",
142
+ "winapi",
143
+]
144
+
145
[[package]]
146
name = "clap"
147
version = "4.1.6"
@@ -164,6 +189,16 @@ dependencies = [
189
"roff",
190
]
191
192
+[[package]]
193
+name = "codespan-reporting"
194
+version = "0.11.1"
195
+source = "registry+https://github.com/rust-lang/crates.io-index"
196
+checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
197
+dependencies = [
198
+ "termcolor",
199
+ "unicode-width",
200
+]
201
+
202
[[package]]
203
name = "console"
204
version = "0.15.5"
@@ -193,6 +228,50 @@ version = "0.8.3"
228
source = "registry+https://github.com/rust-lang/crates.io-index"
229
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
230
231
+[[package]]
232
+name = "cxx"
233
+version = "1.0.92"
234
+source = "registry+https://github.com/rust-lang/crates.io-index"
235
+checksum = "9a140f260e6f3f79013b8bfc65e7ce630c9ab4388c6a89c71e07226f49487b72"
236
+dependencies = [
237
+ "cc",
238
+ "cxxbridge-flags",
239
+ "cxxbridge-macro",
240
+ "link-cplusplus",
241
+]
242
+
243
+[[package]]
244
+name = "cxx-build"
245
+version = "1.0.92"
246
+source = "registry+https://github.com/rust-lang/crates.io-index"
247
+checksum = "da6383f459341ea689374bf0a42979739dc421874f112ff26f829b8040b8e613"
248
+dependencies = [
249
+ "cc",
250
+ "codespan-reporting",
251
+ "once_cell",
252
+ "proc-macro2",
253
+ "quote",
254
+ "scratch",
255
+ "syn",
256
+]
257
+
258
+[[package]]
259
+name = "cxxbridge-flags"
260
+version = "1.0.92"
261
+source = "registry+https://github.com/rust-lang/crates.io-index"
262
+checksum = "90201c1a650e95ccff1c8c0bb5a343213bdd317c6e600a93075bca2eff54ec97"
263
+
264
+[[package]]
265
+name = "cxxbridge-macro"
266
+version = "1.0.92"
267
+source = "registry+https://github.com/rust-lang/crates.io-index"
268
+checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56"
269
+dependencies = [
270
+ "proc-macro2",
271
+ "quote",
272
+ "syn",
273
+]
274
+
275
[[package]]
276
name = "dialoguer"
277
version = "0.10.4"
@@ -363,7 +442,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
442
dependencies = [
443
"cfg-if",
444
"libc",
366
- "wasi",
445
+ "wasi 0.11.0+wasi-snapshot-preview1",
446
]
447
448
[[package]]
@@ -492,6 +571,30 @@ dependencies = [
571
"tokio-native-tls",
572
]
573
574
+[[package]]
575
+name = "iana-time-zone"
576
+version = "0.1.56"
577
+source = "registry+https://github.com/rust-lang/crates.io-index"
578
+checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c"
579
+dependencies = [
580
+ "android_system_properties",
581
+ "core-foundation-sys",
582
+ "iana-time-zone-haiku",
583
+ "js-sys",
584
+ "wasm-bindgen",
585
+ "windows",
586
+]
587
+
588
+[[package]]
589
+name = "iana-time-zone-haiku"
590
+version = "0.1.1"
591
+source = "registry+https://github.com/rust-lang/crates.io-index"
592
+checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
593
+dependencies = [
594
+ "cxx",
595
+ "cxx-build",
596
+]
597
+
598
[[package]]
599
name = "idna"
600
version = "0.3.0"
@@ -576,6 +679,15 @@ version = "0.2.139"
679
source = "registry+https://github.com/rust-lang/crates.io-index"
680
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
681
682
+[[package]]
683
+name = "link-cplusplus"
684
+version = "1.0.8"
685
+source = "registry+https://github.com/rust-lang/crates.io-index"
686
+checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5"
687
+dependencies = [
688
+ "cc",
689
+]
690
+
691
[[package]]
692
name = "linux-raw-sys"
693
version = "0.1.4"
@@ -647,7 +759,7 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
759
dependencies = [
760
"libc",
761
"log",
650
- "wasi",
762
+ "wasi 0.11.0+wasi-snapshot-preview1",
763
"windows-sys 0.45.0",
764
]
765
@@ -679,6 +791,25 @@ dependencies = [
791
"winapi",
792
]
793
794
+[[package]]
795
+name = "num-integer"
796
+version = "0.1.45"
797
+source = "registry+https://github.com/rust-lang/crates.io-index"
798
+checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
799
+dependencies = [
800
+ "autocfg",
801
+ "num-traits",
802
+]
803
+
804
+[[package]]
805
+name = "num-traits"
806
+version = "0.2.15"
807
+source = "registry+https://github.com/rust-lang/crates.io-index"
808
+checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
809
+dependencies = [
810
+ "autocfg",
811
+]
812
+
813
[[package]]
814
name = "num_cpus"
815
version = "1.15.0"
@@ -1004,6 +1135,12 @@ version = "1.1.0"
1135
source = "registry+https://github.com/rust-lang/crates.io-index"
1136
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
1137
1138
+[[package]]
1139
+name = "scratch"
1140
+version = "1.0.5"
1141
+source = "registry+https://github.com/rust-lang/crates.io-index"
1142
+checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1"
1143
+
1144
[[package]]
1145
name = "security-framework"
1146
version = "2.8.2"
@@ -1157,6 +1294,7 @@ dependencies = [
1294
name = "smbpndk-model"
1295
version = "0.1.0"
1296
dependencies = [
1297
+ "chrono",
1298
"serde",
1299
"serde_json",
1300
"spinners",
@@ -1324,6 +1462,17 @@ dependencies = [
1462
"once_cell",
1463
]
1464
1465
+[[package]]
1466
+name = "time"
1467
+version = "0.1.45"
1468
+source = "registry+https://github.com/rust-lang/crates.io-index"
1469
+checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
1470
+dependencies = [
1471
+ "libc",
1472
+ "wasi 0.10.0+wasi-snapshot-preview1",
1473
+ "winapi",
1474
+]
1475
+
1476
[[package]]
1477
name = "time"
1478
version = "0.3.19"
@@ -1496,7 +1645,7 @@ dependencies = [
1645
"log",
1646
"serde",
1647
"serde_json",
1499
- "time",
1648
+ "time 0.3.19",
1649
"tracing",
1650
"tracing-core",
1651
"tracing-log",
@@ -1620,6 +1769,12 @@ dependencies = [
1769
"try-lock",
1770
]
1771
1772
+[[package]]
1773
+name = "wasi"
1774
+version = "0.10.0+wasi-snapshot-preview1"
1775
+source = "registry+https://github.com/rust-lang/crates.io-index"
1776
+checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
1777
+
1778
[[package]]
1779
name = "wasi"
1780
version = "0.11.0+wasi-snapshot-preview1"
@@ -1733,19 +1888,28 @@ version = "0.4.0"
1888
source = "registry+https://github.com/rust-lang/crates.io-index"
1889
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
1890
1891
+[[package]]
1892
+name = "windows"
1893
+version = "0.48.0"
1894
+source = "registry+https://github.com/rust-lang/crates.io-index"
1895
+checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
1896
+dependencies = [
1897
+ "windows-targets 0.48.0",
1898
+]
1899
+
1900
[[package]]
1901
name = "windows-sys"
1902
version = "0.42.0"
1903
source = "registry+https://github.com/rust-lang/crates.io-index"
1904
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
1905
dependencies = [
1742
- "windows_aarch64_gnullvm",
1743
- "windows_aarch64_msvc",
1744
- "windows_i686_gnu",
1745
- "windows_i686_msvc",
1746
- "windows_x86_64_gnu",
1747
- "windows_x86_64_gnullvm",
1748
- "windows_x86_64_msvc",
1906
+ "windows_aarch64_gnullvm 0.42.1",
1907
+ "windows_aarch64_msvc 0.42.1",
1908
+ "windows_i686_gnu 0.42.1",
1909
+ "windows_i686_msvc 0.42.1",
1910
+ "windows_x86_64_gnu 0.42.1",
1911
+ "windows_x86_64_gnullvm 0.42.1",
1912
+ "windows_x86_64_msvc 0.42.1",
1913
]
1914
1915
[[package]]
@@ -1754,7 +1918,7 @@ version = "0.45.0"
1918
source = "registry+https://github.com/rust-lang/crates.io-index"
1919
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
1920
dependencies = [
1757
- "windows-targets",
1921
+ "windows-targets 0.42.1",
1922
]
1923
1924
[[package]]
@@ -1763,13 +1927,28 @@ version = "0.42.1"
1927
source = "registry+https://github.com/rust-lang/crates.io-index"
1928
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
1929
dependencies = [
1766
- "windows_aarch64_gnullvm",
1767
- "windows_aarch64_msvc",
1768
- "windows_i686_gnu",
1769
- "windows_i686_msvc",
1770
- "windows_x86_64_gnu",
1771
- "windows_x86_64_gnullvm",
1772
- "windows_x86_64_msvc",
1930
+ "windows_aarch64_gnullvm 0.42.1",
1931
+ "windows_aarch64_msvc 0.42.1",
1932
+ "windows_i686_gnu 0.42.1",
1933
+ "windows_i686_msvc 0.42.1",
1934
+ "windows_x86_64_gnu 0.42.1",
1935
+ "windows_x86_64_gnullvm 0.42.1",
1936
+ "windows_x86_64_msvc 0.42.1",
1937
+]
1938
+
1939
+[[package]]
1940
+name = "windows-targets"
1941
+version = "0.48.0"
1942
+source = "registry+https://github.com/rust-lang/crates.io-index"
1943
+checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
1944
+dependencies = [
1945
+ "windows_aarch64_gnullvm 0.48.0",
1946
+ "windows_aarch64_msvc 0.48.0",
1947
+ "windows_i686_gnu 0.48.0",
1948
+ "windows_i686_msvc 0.48.0",
1949
+ "windows_x86_64_gnu 0.48.0",
1950
+ "windows_x86_64_gnullvm 0.48.0",
1951
+ "windows_x86_64_msvc 0.48.0",
1952
]
1953
1954
[[package]]
@@ -1778,42 +1957,84 @@ version = "0.42.1"
1957
source = "registry+https://github.com/rust-lang/crates.io-index"
1958
checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
1959
1960
+[[package]]
1961
+name = "windows_aarch64_gnullvm"
1962
+version = "0.48.0"
1963
+source = "registry+https://github.com/rust-lang/crates.io-index"
1964
+checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
1965
+
1966
[[package]]
1967
name = "windows_aarch64_msvc"
1968
version = "0.42.1"
1969
source = "registry+https://github.com/rust-lang/crates.io-index"
1970
checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
1971
1972
+[[package]]
1973
+name = "windows_aarch64_msvc"
1974
+version = "0.48.0"
1975
+source = "registry+https://github.com/rust-lang/crates.io-index"
1976
+checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
1977
+
1978
[[package]]
1979
name = "windows_i686_gnu"
1980
version = "0.42.1"
1981
source = "registry+https://github.com/rust-lang/crates.io-index"
1982
checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
1983
1984
+[[package]]
1985
+name = "windows_i686_gnu"
1986
+version = "0.48.0"
1987
+source = "registry+https://github.com/rust-lang/crates.io-index"
1988
+checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
1989
+
1990
[[package]]
1991
name = "windows_i686_msvc"
1992
version = "0.42.1"
1993
source = "registry+https://github.com/rust-lang/crates.io-index"
1994
checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
1995
1996
+[[package]]
1997
+name = "windows_i686_msvc"
1998
+version = "0.48.0"
1999
+source = "registry+https://github.com/rust-lang/crates.io-index"
2000
+checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
2001
+
2002
[[package]]
2003
name = "windows_x86_64_gnu"
2004
version = "0.42.1"
2005
source = "registry+https://github.com/rust-lang/crates.io-index"
2006
checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
2007
2008
+[[package]]
2009
+name = "windows_x86_64_gnu"
2010
+version = "0.48.0"
2011
+source = "registry+https://github.com/rust-lang/crates.io-index"
2012
+checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
2013
+
2014
[[package]]
2015
name = "windows_x86_64_gnullvm"
2016
version = "0.42.1"
2017
source = "registry+https://github.com/rust-lang/crates.io-index"
2018
checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
2019
2020
+[[package]]
2021
+name = "windows_x86_64_gnullvm"
2022
+version = "0.48.0"
2023
+source = "registry+https://github.com/rust-lang/crates.io-index"
2024
+checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
2025
+
2026
[[package]]
2027
name = "windows_x86_64_msvc"
2028
version = "0.42.1"
2029
source = "registry+https://github.com/rust-lang/crates.io-index"
2030
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
2031
2032
+[[package]]
2033
+name = "windows_x86_64_msvc"
2034
+version = "0.48.0"
2035
+source = "registry+https://github.com/rust-lang/crates.io-index"
2036
+checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
2037
+
2038
[[package]]
2039
name = "winnow"
2040
version = "0.4.4"
app-oten/src/handler.rs
+6
-3
@@ -53,13 +53,16 @@ pub async fn process_auth_app(commands: Commands) -> Result<CommandResult> {
53
Ok(auth_apps) => {
54
println!("auth_apps: {auth_apps:#?}");
55
println!(
56
- "{0: <5} | {1: <20} | {2: <30} | {3: <30}",
56
+ "{0: <10} | {1: <30} | {2: <10} | {3: <10}",
57
"ID", "Name", "Created at", "Updated at"
58
);
59
for project in auth_apps {
60
+ let id = project.id.split("-").collect::<Vec<&str>>()[0].to_owned();
61
+ let created_at = project.created_at.date_naive();
62
+ let updated_at = project.updated_at.date_naive();
63
println!(
61
- "{0: <5} | {1: <20} | {2: <30} | {3: <30}",
62
- project.id, project.name, project.created_at, project.updated_at
64
+ "{0: <10} | {1: <30} | {2: <10} | {3: <10}",
65
+ id, project.name, created_at, updated_at
66
);
67
}
68
Ok(CommandResult {
smbpndk-cli/Cargo.toml
+1
-1
@@ -17,9 +17,9 @@ path = "src/main.rs"
17
18
[dependencies]
19
anyhow = "1.0.58"
20
-app-pkt = { path = "../app-pkt" }
20
app-fun = { path = "../app-fun" }
21
app-oten = { path = "../app-oten" }
22
+app-pkt = { path = "../app-pkt" }
23
app-rdb = { path = "../app-rdb" }
24
clap = { version = "4.1.6", features = ["derive"] }
25
clap_mangen = "0.2.10"
smbpndk-cli/src/project/mod.rs
+5
-2
@@ -59,13 +59,16 @@ pub async fn process_project(commands: Commands) -> Result<CommandResult> {
59
Ok(projects) => {
60
println!("Projects: {projects:#?}");
61
println!(
62
- "{0: <5} | {1: <20} | {2: <30} | {3: <30}",
62
+ "{0: <5} | {1: <20} | {2: <10} | {3: <10}",
63
"ID", "Name", "Created at", "Updated at"
64
);
65
for project in projects {
66
println!(
67
"{0: <5} | {1: <20} | {2: <30} | {3: <30}",
68
- project.id, project.name, project.created_at, project.updated_at
68
+ project.id,
69
+ project.name,
70
+ project.created_at.date_naive(),
71
+ project.updated_at.date_naive()
72
);
73
}
74
Ok(CommandResult {
smbpndk-model/Cargo.toml
+1
@@ -8,3 +8,4 @@ edition = "2021"
8
serde = { version = "1", features = ["derive"] }
9
serde_json = "1.0.82"
10
spinners = "4.1.0"
11
+chrono = { version = "0.4", features = ["serde"] }
smbpndk-model/src/lib.rs
+47
-4
@@ -1,6 +1,45 @@
1
+use chrono::{DateTime, Utc};
2
use serde::{Deserialize, Serialize};
3
use spinners::Spinner;
4
5
+mod ar_date_format {
6
+ use chrono::{DateTime, TimeZone, Utc};
7
+ use serde::{self, Deserialize, Deserializer, Serializer};
8
+
9
+ const FORMAT: &'static str = "%Y-%m-%dT%H:%M:%S%.f%#z";
10
+
11
+ // The signature of a serialize_with function must follow the pattern:
12
+ //
13
+ // fn serialize<S>(&T, S) -> Result<S::Ok, S::Error>
14
+ // where
15
+ // S: Serializer
16
+ //
17
+ // although it may also be generic over the input types T.
18
+ pub fn serialize<S>(date: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error>
19
+ where
20
+ S: Serializer,
21
+ {
22
+ let s = format!("{}", date.naive_utc());
23
+ serializer.serialize_str(&s)
24
+ }
25
+
26
+ // The signature of a deserialize_with function must follow the pattern:
27
+ //
28
+ // fn deserialize<'de, D>(D) -> Result<T, D::Error>
29
+ // where
30
+ // D: Deserializer<'de>
31
+ //
32
+ // although it may also be generic over the output types T.
33
+ pub fn deserialize<'de, D>(deserializer: D) -> Result<DateTime<Utc>, D::Error>
34
+ where
35
+ D: Deserializer<'de>,
36
+ {
37
+ let s = String::deserialize(deserializer)?;
38
+ Utc.datetime_from_str(&s, FORMAT)
39
+ .map_err(serde::de::Error::custom)
40
+ }
41
+}
42
+
43
pub struct CommandResult {
44
pub spinner: Spinner,
45
pub symbol: String,
@@ -12,8 +51,10 @@ pub struct AuthApp {
51
pub id: String,
52
pub secret: Option<String>,
53
pub name: String,
15
- pub created_at: String,
16
- pub updated_at: String,
54
+ #[serde(with = "ar_date_format")]
55
+ pub created_at: DateTime<Utc>,
56
+ #[serde(with = "ar_date_format")]
57
+ pub updated_at: DateTime<Utc>,
58
}
59
60
#[derive(Serialize, Deserialize, Debug)]
@@ -32,8 +73,10 @@ pub struct Config {
73
pub struct Project {
74
pub id: i32,
75
pub name: String,
35
- pub created_at: String,
36
- pub updated_at: String,
76
+ #[serde(with = "ar_date_format")]
77
+ pub created_at: DateTime<Utc>,
78
+ #[serde(with = "ar_date_format")]
79
+ pub updated_at: DateTime<Utc>,
80
}
81
#[derive(Serialize, Debug)]
82
pub struct ProjectCreate {