Compare commits
4 Commits
643d44caad
...
experiment
| Author | SHA1 | Date | |
|---|---|---|---|
|
0ca86560bf
|
|||
|
50e4d5a879
|
|||
|
5fbae8abd6
|
|||
|
88ed032ef0
|
336
Cargo.lock
generated
336
Cargo.lock
generated
@@ -45,10 +45,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.78"
|
||||
name = "bytes"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d"
|
||||
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
@@ -57,21 +63,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "char"
|
||||
name = "char_cli"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"color-eyre",
|
||||
"eyre",
|
||||
"serde",
|
||||
"toml",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "char_plan"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"char_sdk",
|
||||
"char_sdk_derive",
|
||||
"eyre",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "char_sdk"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"eyre",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "char_sdk_derive"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.1.1"
|
||||
version = "4.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ec7a4128863c188deefe750ac1d1dfe66c236909f845af04beed823638dc1b2"
|
||||
checksum = "ec0b0588d44d4d63a87dbd75c136c166bbfd9a86a31cb89e09906521c7d3f5e3"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"clap_lex",
|
||||
@@ -149,15 +182,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.27.0"
|
||||
version = "0.27.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dec7af912d60cdbd3677c1af9352ebae6fb8394d165568a2234df0fa00f87793"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
@@ -168,42 +195,38 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
|
||||
|
||||
[[package]]
|
||||
name = "indenter"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io-lifetimes"
|
||||
version = "1.0.4"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e"
|
||||
checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189"
|
||||
checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"hermit-abi 0.3.1",
|
||||
"io-lifetimes",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -224,6 +247,25 @@ version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
@@ -240,19 +282,51 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.30.2"
|
||||
name = "mio"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b8c786513eb403643f2a88c244c2aaa270ef2153f55094587d0c48a3cf22a83"
|
||||
checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
|
||||
dependencies = [
|
||||
"overload",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
|
||||
dependencies = [
|
||||
"hermit-abi 0.2.6",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.30.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.17.0"
|
||||
version = "1.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
|
||||
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
@@ -260,12 +334,41 @@ version = "6.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||
|
||||
[[package]]
|
||||
name = "owo-colors"
|
||||
version = "3.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.9"
|
||||
@@ -274,9 +377,9 @@ checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.50"
|
||||
version = "1.0.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2"
|
||||
checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -290,6 +393,15 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.21"
|
||||
@@ -298,37 +410,23 @@ checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.36.7"
|
||||
version = "0.36.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03"
|
||||
checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"io-lifetimes",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.152"
|
||||
name = "scopeguard"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.152"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
@@ -339,6 +437,31 @@ dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
@@ -367,21 +490,43 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.4"
|
||||
version = "1.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
|
||||
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.11"
|
||||
name = "tokio"
|
||||
version = "1.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
|
||||
checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
"autocfg",
|
||||
"bytes",
|
||||
"libc",
|
||||
"memchr",
|
||||
"mio",
|
||||
"num_cpus",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "1.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -391,10 +536,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"log",
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.30"
|
||||
@@ -415,15 +573,29 @@ dependencies = [
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
|
||||
dependencies = [
|
||||
"nu-ansi-term",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -438,6 +610,12 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
@@ -484,6 +662,30 @@ dependencies = [
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.45.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.42.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.42.1"
|
||||
|
||||
22
Cargo.toml
22
Cargo.toml
@@ -1,13 +1,13 @@
|
||||
[package]
|
||||
name = "char"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
[workspace]
|
||||
members = [
|
||||
"examples/service/char_plan",
|
||||
"crates/char_cli",
|
||||
"crates/char_sdk",
|
||||
"crates/char_sdk_derive",
|
||||
]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
clap = "4.1.1"
|
||||
color-eyre = "0.6.2"
|
||||
[workspace.dependencies]
|
||||
eyre = "0.6.8"
|
||||
serde = { version = "1.0.152", features = ["derive"] }
|
||||
toml = { version = "0.5.11", features = ["preserve_order"] }
|
||||
color-eyre = "0.6.2"
|
||||
tokio = { version = "1.25.0", features = ["full"] }
|
||||
tracing = { version = "0.1.37", features = ["log"] }
|
||||
|
||||
15
crates/char_cli/Cargo.toml
Normal file
15
crates/char_cli/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "char_cli"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
||||
eyre = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
color-eyre = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tracing-subscriber = "0.3.16"
|
||||
clap = "4.1.6"
|
||||
@@ -1,3 +1,4 @@
|
||||
fn main() {
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
[package]
|
||||
name = "actions"
|
||||
name = "char_sdk"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
eyre = { workspace = true }
|
||||
clap = "4.1.6"
|
||||
53
crates/char_sdk/src/lib.rs
Normal file
53
crates/char_sdk/src/lib.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
pub mod std;
|
||||
|
||||
pub enum ActionArg<'a> {
|
||||
Required { name: &'a str, description: &'a str },
|
||||
Optional { name: &'a str, description: &'a str },
|
||||
}
|
||||
|
||||
pub struct InputArg<'a> {
|
||||
name: &'a str,
|
||||
value: &'a str,
|
||||
}
|
||||
|
||||
pub struct ActionArgs<'a> {
|
||||
pub name: &'a str,
|
||||
pub args: Vec<ActionArg<'a>>,
|
||||
}
|
||||
|
||||
pub trait Action {
|
||||
fn action<'a>(&self) -> ActionArgs<'a>;
|
||||
fn execute(&self, args: &[&InputArg]) -> eyre::Result<()>;
|
||||
}
|
||||
|
||||
pub trait Plugin {}
|
||||
|
||||
pub struct CharBuilder {
|
||||
actions: Vec<Box<dyn Action>>,
|
||||
}
|
||||
|
||||
impl CharBuilder {
|
||||
pub fn new() -> Self {
|
||||
CharBuilder {
|
||||
actions: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_context<C>(mut self, context: C) -> Self {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn add_action(mut self, action: impl Into<Box<dyn Action>>) -> Self {
|
||||
self.actions.push(action.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn add_plugin(mut self, plugin: impl Plugin) -> Self {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn execute(mut self) -> eyre::Result<()> {
|
||||
//clap::Command::new("").arg(a)
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
9
crates/char_sdk/src/std/dagger/mod.rs
Normal file
9
crates/char_sdk/src/std/dagger/mod.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
pub struct Plugin {}
|
||||
|
||||
impl crate::Plugin for Plugin {}
|
||||
|
||||
impl Default for Plugin {
|
||||
fn default() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
9
crates/char_sdk/src/std/k8s/mod.rs
Normal file
9
crates/char_sdk/src/std/k8s/mod.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
pub struct Plugin {}
|
||||
|
||||
impl crate::Plugin for Plugin {}
|
||||
|
||||
impl Default for Plugin {
|
||||
fn default() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
2
crates/char_sdk/src/std/mod.rs
Normal file
2
crates/char_sdk/src/std/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod dagger;
|
||||
pub mod k8s;
|
||||
@@ -1,8 +1,12 @@
|
||||
[package]
|
||||
name = "org"
|
||||
name = "char_sdk_derive"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
syn = "1.0.107"
|
||||
quote = "1.0.23"
|
||||
[lib]
|
||||
proc-macro = true
|
||||
24
crates/char_sdk_derive/src/lib.rs
Normal file
24
crates/char_sdk_derive/src/lib.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
|
||||
#[proc_macro_derive(CharAction)]
|
||||
pub fn derive_char_action_into_box(input: TokenStream) -> TokenStream {
|
||||
let ast = syn::parse(input).unwrap();
|
||||
|
||||
// Build the trait implementation
|
||||
impl_hello_macro(&ast)
|
||||
}
|
||||
|
||||
fn impl_hello_macro(ast: &syn::DeriveInput) -> TokenStream {
|
||||
let name = &ast.ident;
|
||||
let gen = quote! {
|
||||
impl Into<Box<dyn char_sdk::Action>> for #name {
|
||||
fn into(self) -> Box<dyn char_sdk::Action> {
|
||||
Box::new(self)
|
||||
}
|
||||
}
|
||||
};
|
||||
gen.into()
|
||||
}
|
||||
@@ -1,2 +1,8 @@
|
||||
[char]
|
||||
plan = "plans/base/"
|
||||
|
||||
[config.docker]
|
||||
something = "something"
|
||||
|
||||
[config.k8s]
|
||||
something = "else"
|
||||
|
||||
7
examples/service/char/actions/Cargo.lock
generated
7
examples/service/char/actions/Cargo.lock
generated
@@ -1,7 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "actions"
|
||||
version = "0.1.0"
|
||||
@@ -1,3 +0,0 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{"rustc_fingerprint":7678195607898329254,"outputs":{"10376369925670944939":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/kah/.rustup/toolchains/nightly-aarch64-apple-darwin\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"aarch64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"aes\"\ntarget_feature=\"crc\"\ntarget_feature=\"dit\"\ntarget_feature=\"dotprod\"\ntarget_feature=\"dpb\"\ntarget_feature=\"dpb2\"\ntarget_feature=\"fcma\"\ntarget_feature=\"fhm\"\ntarget_feature=\"flagm\"\ntarget_feature=\"fp16\"\ntarget_feature=\"frintts\"\ntarget_feature=\"jsconv\"\ntarget_feature=\"llvm14-builtins-abi\"\ntarget_feature=\"lor\"\ntarget_feature=\"lse\"\ntarget_feature=\"neon\"\ntarget_feature=\"paca\"\ntarget_feature=\"pacg\"\ntarget_feature=\"pan\"\ntarget_feature=\"pmuv3\"\ntarget_feature=\"ras\"\ntarget_feature=\"rcpc\"\ntarget_feature=\"rcpc2\"\ntarget_feature=\"rdm\"\ntarget_feature=\"sb\"\ntarget_feature=\"sha2\"\ntarget_feature=\"sha3\"\ntarget_feature=\"ssbs\"\ntarget_feature=\"v8.1a\"\ntarget_feature=\"v8.2a\"\ntarget_feature=\"v8.3a\"\ntarget_feature=\"v8.4a\"\ntarget_feature=\"vh\"\ntarget_has_atomic\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"128\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"apple\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.69.0-nightly (1e225413a 2023-01-28)\nbinary: rustc\ncommit-hash: 1e225413a21fa69570bd3fefea9eb05e33f8b917\ncommit-date: 2023-01-28\nhost: aarch64-apple-darwin\nrelease: 1.69.0-nightly\nLLVM version: 15.0.7\n","stderr":""},"15697416045686424142":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n","stderr":""}},"successes":{}}
|
||||
@@ -1,3 +0,0 @@
|
||||
Signature: 8a477f597d28d172789f06886806bc55
|
||||
# This file is a cache directory tag created by cargo.
|
||||
# For information about cache directory tags see https://bford.info/cachedir/
|
||||
@@ -1 +0,0 @@
|
||||
baa57697ce65b314
|
||||
@@ -1 +0,0 @@
|
||||
{"rustc":15520539443732555526,"features":"[]","target":10808372008975436347,"profile":11736316127369858332,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/org-2413d5d1cd4f3ae1/dep-bin-org"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
This file has an mtime of when this was started.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +0,0 @@
|
||||
/Users/kah/git/git.front.kjuulh.io/kjuulh/char/examples/service/char/overrides/org/target/debug/deps/org-2413d5d1cd4f3ae1: src/main.rs
|
||||
|
||||
/Users/kah/git/git.front.kjuulh.io/kjuulh/char/examples/service/char/overrides/org/target/debug/deps/org-2413d5d1cd4f3ae1.d: src/main.rs
|
||||
|
||||
src/main.rs:
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
/Users/kah/git/git.front.kjuulh.io/kjuulh/char/examples/service/char/overrides/org/target/debug/org: /Users/kah/git/git.front.kjuulh.io/kjuulh/char/examples/service/char/overrides/org/src/main.rs
|
||||
@@ -3,5 +3,5 @@
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "org"
|
||||
name = "char"
|
||||
version = "0.1.0"
|
||||
13
examples/service/char_plan/Cargo.toml
Normal file
13
examples/service/char_plan/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "char_plan"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
char_sdk = { path = "../../../crates/char_sdk" }
|
||||
char_sdk_derive = { path = "../../../crates/char_sdk_derive" }
|
||||
|
||||
eyre = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
43
examples/service/char_plan/src/main.rs
Normal file
43
examples/service/char_plan/src/main.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use char_sdk_derive::CharAction;
|
||||
|
||||
#[derive(CharAction)]
|
||||
struct Run;
|
||||
|
||||
impl char_sdk::Action for Run {
|
||||
fn action<'a>(&self) -> char_sdk::ActionArgs<'a> {
|
||||
char_sdk::ActionArgs {
|
||||
name: "run",
|
||||
args: vec![char_sdk::ActionArg::Required {
|
||||
name: "profile",
|
||||
description: "which release profile to use, takes ['release', 'test']",
|
||||
}],
|
||||
}
|
||||
}
|
||||
|
||||
fn execute(&self, args: &[&char_sdk::InputArg]) -> eyre::Result<()> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(CharAction)]
|
||||
struct Build;
|
||||
|
||||
impl char_sdk::Action for Build {
|
||||
fn action<'a>(&self) -> char_sdk::ActionArgs<'a> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn execute(&self, args: &[&char_sdk::InputArg]) -> eyre::Result<()> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
char_sdk::CharBuilder::new()
|
||||
.add_action(Run {})
|
||||
.add_action(Build {})
|
||||
.add_plugin(char_sdk::std::dagger::Plugin::default())
|
||||
.add_plugin(char_sdk::std::k8s::Plugin::default())
|
||||
.execute()
|
||||
.unwrap();
|
||||
}
|
||||
44
src/cli.rs
44
src/cli.rs
@@ -1,44 +0,0 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::{
|
||||
deps,
|
||||
resolvers::{install, Resolver},
|
||||
};
|
||||
|
||||
pub struct Cli {
|
||||
deps: deps::Deps,
|
||||
install: Box<dyn Resolver + Send + Sync>,
|
||||
}
|
||||
|
||||
impl Cli {
|
||||
pub fn new(deps: deps::Deps) -> eyre::Result<Self> {
|
||||
Ok(Self {
|
||||
deps: deps.clone(),
|
||||
install: install::Install::new(deps),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn matches(self, args: &[&str]) -> eyre::Result<()> {
|
||||
let mut cli = clap::Command::new("char")
|
||||
.arg(clap::Arg::new("path").long("path").short('p'))
|
||||
.subcommand(self.install.cmd()?);
|
||||
|
||||
let matches = cli.clone().get_matches_from(args);
|
||||
|
||||
let path = matches.get_one::<String>("path");
|
||||
if let Some(p) = path {
|
||||
let path = PathBuf::from(p);
|
||||
if !path.exists() {
|
||||
eyre::bail!("no char.toml exists at --path")
|
||||
}
|
||||
self.deps.parser.set_path(path);
|
||||
}
|
||||
|
||||
match matches.subcommand() {
|
||||
Some(("install", args)) => self.install.matches(args)?,
|
||||
_ => cli.print_help()?,
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
use crate::models::Char;
|
||||
|
||||
pub struct Context {}
|
||||
|
||||
impl Context {
|
||||
pub fn new(chars: Vec<Char>) -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ContextBuilder {
|
||||
chars: Vec<Char>,
|
||||
}
|
||||
|
||||
impl ContextBuilder {
|
||||
pub fn new() -> Self {
|
||||
Self { chars: vec![] }
|
||||
}
|
||||
|
||||
pub fn add_char(mut self, char: &Char) -> Self {
|
||||
self.chars.push(char.clone());
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build(self) -> Context {
|
||||
Context::new(self.chars)
|
||||
}
|
||||
}
|
||||
33
src/deps.rs
33
src/deps.rs
@@ -1,33 +0,0 @@
|
||||
use std::{ops::Deref, sync::Arc};
|
||||
|
||||
use crate::{parser::Parser, services::downloader::Downloader};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Deps {
|
||||
inner: Arc<InnerDeps>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct InnerDeps {
|
||||
pub parser: Parser,
|
||||
pub downloader: Downloader,
|
||||
}
|
||||
|
||||
impl Default for Deps {
|
||||
fn default() -> Self {
|
||||
let parser = Parser::default();
|
||||
let downloader = Downloader::new(parser.clone());
|
||||
|
||||
Self {
|
||||
inner: Arc::new(InnerDeps { parser, downloader }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for Deps {
|
||||
type Target = Arc<InnerDeps>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.inner
|
||||
}
|
||||
}
|
||||
32
src/main.rs
32
src/main.rs
@@ -1,32 +0,0 @@
|
||||
pub mod cli;
|
||||
mod context;
|
||||
mod deps;
|
||||
mod models;
|
||||
mod parser;
|
||||
mod resolvers;
|
||||
mod services;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
color_eyre::install()?;
|
||||
|
||||
let args = std::env::args();
|
||||
|
||||
let deps = deps::Deps::default();
|
||||
|
||||
let c = cli::Cli::new(deps)?;
|
||||
c.matches(
|
||||
args.collect::<Vec<String>>()
|
||||
.iter()
|
||||
.map(|s| s.as_str())
|
||||
.collect::<Vec<&str>>()
|
||||
.as_slice(),
|
||||
)?;
|
||||
|
||||
let p = std::path::PathBuf::from("examples/service/char.toml");
|
||||
|
||||
let char = std::fs::read_to_string(p)?.parse::<models::Char>()?;
|
||||
|
||||
dbg!(char);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
type Overrides = BTreeMap<String, String>;
|
||||
type Dependencies = Vec<String>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct Conf {
|
||||
pub plan: String,
|
||||
pub dependencies: Option<Dependencies>,
|
||||
pub overrides: Option<Overrides>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct Application {
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct Plan {
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(untagged)]
|
||||
pub enum Char {
|
||||
Application {
|
||||
char: Option<Conf>,
|
||||
application: Application,
|
||||
config: BTreeMap<String, toml::Value>,
|
||||
},
|
||||
Plan {
|
||||
char: Option<Conf>,
|
||||
plan: Plan,
|
||||
config: BTreeMap<String, toml::Value>,
|
||||
},
|
||||
}
|
||||
|
||||
impl std::str::FromStr for Char {
|
||||
type Err = eyre::Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let t: Char = toml::from_str(s)?;
|
||||
|
||||
Ok(t)
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
sync::{Arc, RwLock},
|
||||
};
|
||||
|
||||
use eyre::Context;
|
||||
|
||||
use crate::models::{self, Char};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Parser {
|
||||
path: Arc<RwLock<Option<PathBuf>>>,
|
||||
}
|
||||
|
||||
impl Parser {
|
||||
pub fn new(path: PathBuf) -> Self {
|
||||
Self {
|
||||
path: Arc::new(RwLock::new(Some(path))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_path(&self, path: PathBuf) {
|
||||
let mut writer = self.path.write().unwrap();
|
||||
*writer = Some(path);
|
||||
}
|
||||
|
||||
pub fn get_path(&self) -> eyre::Result<PathBuf> {
|
||||
let read_path = self.path.read().unwrap();
|
||||
let path = match read_path.clone() {
|
||||
Some(p) => p,
|
||||
None => todo!(), // find using git later on
|
||||
};
|
||||
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
pub fn parse(&self) -> eyre::Result<models::Char> {
|
||||
let mut path = self.get_path()?;
|
||||
if !path.ends_with("char.toml") {
|
||||
path.push("char.toml")
|
||||
}
|
||||
let contents =
|
||||
std::fs::read_to_string(&path).context("char.toml doesn't exist at that path")?;
|
||||
|
||||
contents.parse::<Char>()
|
||||
}
|
||||
|
||||
pub fn parse_from(&self, path: &PathBuf) -> eyre::Result<models::Char> {
|
||||
let contents =
|
||||
std::fs::read_to_string(path).context("char.toml doesn't exist at that path")?;
|
||||
|
||||
contents.parse::<Char>()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Parser {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
path: Arc::new(RwLock::new(None)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
use crate::deps;
|
||||
|
||||
use super::{DynResolver, Resolver};
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Install {
|
||||
deps: deps::Deps,
|
||||
}
|
||||
|
||||
impl Install {
|
||||
pub fn new(deps: deps::Deps) -> DynResolver {
|
||||
Box::new(Self { deps })
|
||||
}
|
||||
}
|
||||
|
||||
impl Resolver for Install {
|
||||
fn cmd(&self) -> eyre::Result<clap::Command> {
|
||||
let install = clap::Command::new("install");
|
||||
|
||||
Ok(install)
|
||||
}
|
||||
|
||||
fn matches(&self, _args: &clap::ArgMatches) -> eyre::Result<()> {
|
||||
self.deps.downloader.download()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
pub(crate) mod install;
|
||||
|
||||
pub trait Resolver {
|
||||
fn cmd(&self) -> eyre::Result<clap::Command>;
|
||||
fn matches(&self, args: &clap::ArgMatches) -> eyre::Result<()>;
|
||||
}
|
||||
|
||||
pub type DynResolver = Box<dyn Resolver + Send + Sync>;
|
||||
@@ -1,96 +0,0 @@
|
||||
use std::{fs::canonicalize, path::PathBuf};
|
||||
|
||||
use crate::{
|
||||
context::{Context, ContextBuilder},
|
||||
models::{Char, Conf},
|
||||
parser::Parser,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Downloader {
|
||||
parser: Parser,
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
impl Downloader {
|
||||
pub fn new(parser: Parser) -> Self {
|
||||
Self { parser }
|
||||
}
|
||||
|
||||
/// Unfolds char
|
||||
/// 1. Download path
|
||||
/// 2. Parse char in downloaded path
|
||||
/// 3. Repeat from 1. until there are no more parents
|
||||
pub fn download(&self) -> eyre::Result<Context> {
|
||||
let mut context_builder = ContextBuilder::new();
|
||||
|
||||
let char = self.parser.parse()?;
|
||||
context_builder = context_builder.add_char(&char);
|
||||
let first_char_path = self.parser.get_path()?;
|
||||
|
||||
let mut root = std::env::current_dir()?;
|
||||
root = root.join(&first_char_path);
|
||||
root.push(".char");
|
||||
let output = self.create_output_dir(&root)?;
|
||||
|
||||
let mut parent_char = char;
|
||||
let path = first_char_path;
|
||||
loop {
|
||||
parent_char = match &parent_char {
|
||||
Char::Application {
|
||||
char,
|
||||
application: _,
|
||||
config: _,
|
||||
} => match char {
|
||||
Some(c) => self.download_plan(c, &path, &output)?,
|
||||
None => {
|
||||
break;
|
||||
}
|
||||
},
|
||||
Char::Plan {
|
||||
char,
|
||||
plan: _,
|
||||
config: _,
|
||||
} => match char {
|
||||
Some(_c) => todo!(),
|
||||
None => {
|
||||
break;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Ok(context_builder.build())
|
||||
}
|
||||
|
||||
fn download_plan(
|
||||
&self,
|
||||
conf: &Conf,
|
||||
path: &PathBuf,
|
||||
output_path: &PathBuf,
|
||||
) -> eyre::Result<Char> {
|
||||
let plan = &conf.plan;
|
||||
|
||||
// TODO: decide whether it is a file or a git repo
|
||||
// TODO: Starting with files only, as such implement git repo later
|
||||
|
||||
let path_buf = std::path::PathBuf::from(plan);
|
||||
let path = path.join(path_buf);
|
||||
if !path.exists() {
|
||||
eyre::bail!("path doesn't exist: {}", path.to_string_lossy())
|
||||
}
|
||||
let path = canonicalize(path)?;
|
||||
|
||||
dbg!(path);
|
||||
dbg!(output_path);
|
||||
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn create_output_dir(&self, root: &PathBuf) -> eyre::Result<PathBuf> {
|
||||
let mut output = root.clone();
|
||||
output.push("plans");
|
||||
std::fs::create_dir_all(&output)?;
|
||||
|
||||
Ok(output)
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod downloader;
|
||||
Reference in New Issue
Block a user