ui sync version
This commit is contained in:
303
Cargo.lock
generated
303
Cargo.lock
generated
@@ -2,6 +2,21 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.18"
|
||||
@@ -14,6 +29,21 @@ version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.71"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.22.1"
|
||||
@@ -26,6 +56,12 @@ version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9"
|
||||
|
||||
[[package]]
|
||||
name = "cassowary"
|
||||
version = "0.3.0"
|
||||
@@ -41,12 +77,48 @@ dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c736e259eea577f443d5c86c304f9f4ae0295c43f3ba05c21f1d66b5f06001af"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "color-eyre"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"color-spantrace",
|
||||
"eyre",
|
||||
"indenter",
|
||||
"once_cell",
|
||||
"owo-colors",
|
||||
"tracing-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color-spantrace"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"owo-colors",
|
||||
"tracing-core",
|
||||
"tracing-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "compact_str"
|
||||
version = "0.8.0"
|
||||
@@ -139,6 +211,16 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "eyre"
|
||||
version = "0.6.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec"
|
||||
dependencies = [
|
||||
"indenter",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.3"
|
||||
@@ -162,6 +244,12 @@ dependencies = [
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.28.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.0"
|
||||
@@ -186,14 +274,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.6.0"
|
||||
name = "indenter"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "2.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
|
||||
|
||||
[[package]]
|
||||
name = "instability"
|
||||
@@ -228,9 +318,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.159"
|
||||
version = "0.2.170"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
|
||||
checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
@@ -279,6 +369,15 @@ version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
|
||||
dependencies = [
|
||||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.0.2"
|
||||
@@ -307,12 +406,33 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.32.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.20.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
|
||||
|
||||
[[package]]
|
||||
name = "option-ext"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[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.3"
|
||||
@@ -342,6 +462,12 @@ version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
version = "0.2.0"
|
||||
@@ -368,24 +494,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ratatui"
|
||||
version = "0.28.1"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdef7f9be5c0122f890d58bdf4d964349ba6a6161f705907526d891efabba57d"
|
||||
checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cassowary",
|
||||
"compact_str",
|
||||
"crossterm",
|
||||
"indoc",
|
||||
"instability",
|
||||
"itertools",
|
||||
"lru",
|
||||
"paste",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"time",
|
||||
"unicode-segmentation",
|
||||
"unicode-truncate",
|
||||
"unicode-width 0.1.14",
|
||||
"unicode-width 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -413,15 +539,23 @@ name = "rstemp"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"color-eyre",
|
||||
"crossterm",
|
||||
"dirs",
|
||||
"lazy_static",
|
||||
"ratatui",
|
||||
"serde",
|
||||
"toml",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"unicode-width 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.37"
|
||||
@@ -455,18 +589,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.214"
|
||||
version = "1.0.218"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5"
|
||||
checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.214"
|
||||
version = "1.0.218"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766"
|
||||
checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -474,14 +608,32 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.8"
|
||||
name = "serde_json"
|
||||
version = "1.0.139"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"
|
||||
checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook"
|
||||
version = "0.3.17"
|
||||
@@ -518,6 +670,16 @@ version = "1.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
@@ -577,6 +739,16 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.36"
|
||||
@@ -599,37 +771,73 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.19"
|
||||
name = "tokio"
|
||||
version = "1.43.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
|
||||
checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit",
|
||||
"backtrace",
|
||||
"bytes",
|
||||
"libc",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.8"
|
||||
name = "tokio-macros"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
|
||||
checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.22"
|
||||
name = "tracing"
|
||||
version = "0.1.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5"
|
||||
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
"pin-project-lite",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-error"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db"
|
||||
dependencies = [
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
|
||||
dependencies = [
|
||||
"sharded-slab",
|
||||
"thread_local",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -667,6 +875,12 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
@@ -833,12 +1047,3 @@ name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.6.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
@@ -5,10 +5,12 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.22.1"
|
||||
color-eyre = "0.6.3"
|
||||
crossterm = { version = "0.28.1", features = ["event-stream"] }
|
||||
dirs = "5.0.1"
|
||||
lazy_static = "1.5.0"
|
||||
ratatui = { version = "0.28.1", features = ["all-widgets"] }
|
||||
serde = { version = "1.0.214", features = ["derive"] }
|
||||
toml = "0.8.19"
|
||||
ratatui = { version = "0.29.0", features = ["all-widgets"] }
|
||||
serde = { version = "1.0.218", features = ["derive"] }
|
||||
serde_json = "1.0.139"
|
||||
tokio = { version = "1.43.0", features = ["full"] }
|
||||
unicode-width = "0.2.0"
|
||||
|
||||
16
src/app.rs
16
src/app.rs
@@ -1,18 +1,12 @@
|
||||
use std::io;
|
||||
|
||||
use color_eyre::Result;
|
||||
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind};
|
||||
use ratatui::{DefaultTerminal, Frame};
|
||||
|
||||
use crate::{
|
||||
session::{connection::ConnectionManager, credential::CredentialManager},
|
||||
view::{home::Home, View},
|
||||
};
|
||||
use crate::view::{home::Home, View};
|
||||
|
||||
pub struct App {
|
||||
running: bool,
|
||||
view: Home,
|
||||
connection_manager: ConnectionManager,
|
||||
credential_manager: CredentialManager,
|
||||
}
|
||||
|
||||
impl Default for App {
|
||||
@@ -20,14 +14,12 @@ impl Default for App {
|
||||
App {
|
||||
running: true,
|
||||
view: Home::default(),
|
||||
connection_manager: ConnectionManager::default(),
|
||||
credential_manager: CredentialManager::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub fn run(&mut self, terminal: &mut DefaultTerminal) -> io::Result<()> {
|
||||
pub fn run(&mut self, terminal: &mut DefaultTerminal) -> Result<()> {
|
||||
while self.running {
|
||||
terminal.draw(|frame| self.draw(frame))?;
|
||||
self.handle_event()?;
|
||||
@@ -39,7 +31,7 @@ impl App {
|
||||
self.view.draw(frame);
|
||||
}
|
||||
|
||||
fn handle_event(&mut self) -> io::Result<()> {
|
||||
fn handle_event(&mut self) -> Result<()> {
|
||||
match event::read()? {
|
||||
Event::Key(KeyEvent {
|
||||
kind: KeyEventKind::Press,
|
||||
|
||||
59
src/main.rs
59
src/main.rs
@@ -1,13 +1,5 @@
|
||||
use std::{io, path::Path};
|
||||
|
||||
use app::App;
|
||||
use base64::{engine::general_purpose::STANDARD, Engine as _};
|
||||
use session::{
|
||||
connection::{Connection, ConnectionManager, Connections, ShConnection, SshConnection},
|
||||
credential::{Credential, CredentialManager, CredentialType},
|
||||
SessionManager,
|
||||
};
|
||||
use util::file;
|
||||
use color_eyre::Result;
|
||||
|
||||
mod app;
|
||||
mod global;
|
||||
@@ -15,55 +7,10 @@ mod session;
|
||||
mod util;
|
||||
mod view;
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
fn main() -> Result<()> {
|
||||
color_eyre::install()?;
|
||||
let mut terminal = ratatui::init();
|
||||
let app_result = App::default().run(&mut terminal);
|
||||
ratatui::restore();
|
||||
app_result
|
||||
}
|
||||
|
||||
// fn main() -> io::Result<()> {
|
||||
// // let sh = ShConnection::new("zsh".to_string(), "/usr/bin/nu".to_string(), None);
|
||||
// // let _ = sh.exec_cmd();
|
||||
// let ssh = SshConnection::new("".to_string(), "myhost.fallen-angle.com".to_string(), 7044, "rainbus".to_string(), "".to_string());
|
||||
// ssh.exec_cmd();
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
/* fn main() -> io::Result<()> {
|
||||
let mut cnm = ConnectionManager::default();
|
||||
let sh = Connections::Sh(ShConnection::new(
|
||||
"zsh".to_string(),
|
||||
"/usr/bin/zsh".to_string(),
|
||||
None,
|
||||
));
|
||||
let ssh_sec = Connections::Ssh(SshConnection::new(
|
||||
"Tencent".to_string(),
|
||||
"myhost.fallen-angle.com".to_string(),
|
||||
22,
|
||||
"rainbus".to_string(),
|
||||
"Server".to_string(),
|
||||
));
|
||||
let ssh_pwd = Connections::Ssh(SshConnection::new(
|
||||
"Aliyun".to_string(),
|
||||
"myweb.fallen-angle.com".to_string(),
|
||||
22,
|
||||
"rainbus".to_string(),
|
||||
"AliPwd".to_string(),
|
||||
));
|
||||
cnm.connections().extend([sh, ssh_sec, ssh_pwd]);
|
||||
let mut crm = CredentialManager::default();
|
||||
let ser_crd = Credential::new(
|
||||
"Server".to_string(),
|
||||
CredentialType::Secret(STANDARD.encode(file::read_file(Path::new("")))),
|
||||
);
|
||||
let pwd_crd = Credential::new(
|
||||
"Alipwd".to_string(),
|
||||
CredentialType::Password("20001001".to_string()),
|
||||
);
|
||||
crm.credentials().extend([ser_crd, pwd_crd]);
|
||||
let sem = SessionManager::new(cnm, crm);
|
||||
// println!("{}", toml::to_string_pretty(&sem).unwrap());
|
||||
file::write_file(&global::CONFIG_DIR.join("tethers.toml"), toml::to_string_pretty(&sem).unwrap().as_str());
|
||||
Ok(())
|
||||
} */
|
||||
|
||||
@@ -1,21 +1,2 @@
|
||||
use connection::ConnectionManager;
|
||||
use credential::CredentialManager;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod connection;
|
||||
pub mod credential;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct SessionManager {
|
||||
connection_manager: ConnectionManager,
|
||||
credential_manager: CredentialManager,
|
||||
}
|
||||
|
||||
impl SessionManager {
|
||||
pub fn new(cnm: ConnectionManager, crm: CredentialManager) -> Self {
|
||||
Self {
|
||||
connection_manager: cnm,
|
||||
credential_manager: crm,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
use std::{env, fs, io, path::Path, process::Command};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::util::file;
|
||||
|
||||
use super::credential::{Credential, CredentialType};
|
||||
|
||||
pub trait Connection {
|
||||
fn exec_cmd(&self) -> io::Result<()>;
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ShConnection {
|
||||
name: String,
|
||||
path: String,
|
||||
args: Vec<String>,
|
||||
}
|
||||
|
||||
impl Connection for ShConnection {
|
||||
fn exec_cmd(&self) -> io::Result<()> {
|
||||
Command::new(&self.path).args(&self.args).spawn()?.wait()?;
|
||||
Ok(())
|
||||
|
||||
// if output.status.success() {
|
||||
// Ok(String::from_utf8_lossy(&output.stdout).into_owned())
|
||||
// } else {
|
||||
// Err(io::Error::new(
|
||||
// io::ErrorKind::Other,
|
||||
// String::from_utf8_lossy(&output.stderr).into_owned(),
|
||||
// ))
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
impl ShConnection {
|
||||
pub fn new(name: String, path: String, args: Option<Vec<String>>) -> Self {
|
||||
ShConnection {
|
||||
name,
|
||||
path,
|
||||
args: args.unwrap_or_else(Vec::new),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct SshConnection {
|
||||
name: String,
|
||||
host: String,
|
||||
port: u16,
|
||||
user: String,
|
||||
credential_name: String,
|
||||
}
|
||||
|
||||
impl SshConnection {
|
||||
pub fn new(
|
||||
name: String,
|
||||
host: String,
|
||||
port: u16,
|
||||
user: String,
|
||||
credential_name: String,
|
||||
) -> Self {
|
||||
Self {
|
||||
name,
|
||||
host,
|
||||
port,
|
||||
user,
|
||||
credential_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Connection for SshConnection {
|
||||
fn exec_cmd(&self) -> io::Result<()> {
|
||||
let credential = Credential::new(
|
||||
"zsh".to_string(),
|
||||
CredentialType::Secret(file::read_file(Path::new(""))),
|
||||
);
|
||||
let mut ssh_command = Command::new("ssh");
|
||||
let secret_path = env::temp_dir().join("tethers").join("secret.tmp");
|
||||
let _ = fs::create_dir_all(secret_path.parent().unwrap());
|
||||
ssh_command
|
||||
.args(["-p", &self.port.to_string()])
|
||||
.args(["-l", &self.user]);
|
||||
match credential.credential() {
|
||||
CredentialType::Password(pwd) => {
|
||||
println!("{}", pwd);
|
||||
}
|
||||
CredentialType::Secret(secret) => {
|
||||
let _ = credential.write_secret(&secret_path);
|
||||
ssh_command.args(["-i", secret_path.to_str().unwrap()]);
|
||||
println!("{}", secret);
|
||||
}
|
||||
}
|
||||
ssh_command.arg(&self.host);
|
||||
ssh_command.spawn()?.wait()?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum Connections {
|
||||
Sh(ShConnection),
|
||||
Ssh(SshConnection),
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize)]
|
||||
pub struct ConnectionManager {
|
||||
connections: Vec<Connections>,
|
||||
}
|
||||
|
||||
impl ConnectionManager {
|
||||
pub fn connections(&mut self) -> &mut Vec<Connections> {
|
||||
&mut self.connections
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
use std::{
|
||||
fs::OpenOptions,
|
||||
io::{self, Write},
|
||||
os::unix::fs::OpenOptionsExt,
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use base64::{engine::general_purpose::STANDARD, Engine};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum CredentialType {
|
||||
Password(String),
|
||||
Secret(String),
|
||||
}
|
||||
|
||||
impl CredentialType {}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Credential {
|
||||
credential: CredentialType,
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl Credential {
|
||||
pub fn write_secret(&self, secret_path: &Path) -> io::Result<()> {
|
||||
match &self.credential {
|
||||
CredentialType::Secret(secret) => {
|
||||
let mut secret_file = OpenOptions::new()
|
||||
.write(true)
|
||||
.create(true)
|
||||
.mode(0o600)
|
||||
.open(secret_path)?;
|
||||
let _ = secret_file.set_len(0);
|
||||
let _ = secret_file.write_all(secret.as_bytes());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Credential {
|
||||
pub fn new(name: String, credential: CredentialType) -> Self {
|
||||
// TODO: modify this to Type
|
||||
let credential = match credential {
|
||||
CredentialType::Password(password) => {
|
||||
CredentialType::Password(STANDARD.encode(password))
|
||||
}
|
||||
CredentialType::Secret(secret) => CredentialType::Secret(STANDARD.encode(secret)),
|
||||
};
|
||||
Self { name, credential }
|
||||
}
|
||||
|
||||
pub fn credential(&self) -> &CredentialType {
|
||||
&self.credential
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize)]
|
||||
pub struct CredentialManager {
|
||||
credentials: Vec<Credential>,
|
||||
}
|
||||
|
||||
impl CredentialManager {
|
||||
pub fn credentials(&mut self) -> &mut Vec<Credential> {
|
||||
&mut self.credentials
|
||||
}
|
||||
|
||||
pub fn find_by_name(&self, name: &str) -> io::Result<&Credential> {
|
||||
self.credentials
|
||||
.iter()
|
||||
.find(|credential| credential.name == name)
|
||||
.ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "Credential not found"))
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
pub mod file;
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{Read, Write},
|
||||
path::{self, Path},
|
||||
};
|
||||
|
||||
pub fn read_file(path: &Path) -> String {
|
||||
let path = dirs::home_dir().unwrap().join(".ssh/Server");
|
||||
let mut file = File::open(path).unwrap();
|
||||
let mut content = String::new();
|
||||
file.read_to_string(&mut content).unwrap();
|
||||
content
|
||||
}
|
||||
|
||||
pub fn write_file(path: &Path, content: &str) {
|
||||
let mut file = File::create(path).unwrap();
|
||||
let res = file.write_all(content.as_bytes());
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
use std::io;
|
||||
|
||||
use color_eyre::Result;
|
||||
use crossterm::event::Event;
|
||||
use ratatui::{
|
||||
layout::{Flex, Layout, Rect},
|
||||
@@ -12,7 +11,7 @@ pub mod setting;
|
||||
|
||||
pub trait View {
|
||||
fn draw(&self, frame: &mut Frame);
|
||||
fn handle_event(&mut self, event: &Event) -> io::Result<()>;
|
||||
fn handle_event(&mut self, event: &Event) -> Result<()>;
|
||||
}
|
||||
|
||||
pub trait PopupView {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use std::io;
|
||||
|
||||
use color_eyre::Result;
|
||||
use crossterm::event::Event;
|
||||
use ratatui::widgets::Widget;
|
||||
|
||||
@@ -14,6 +13,6 @@ pub mod list;
|
||||
pub trait Component {
|
||||
type EventResult;
|
||||
fn widget(&self) -> impl Widget;
|
||||
fn event_handler(&mut self, event: &Event) -> io::Result<Self::EventResult>;
|
||||
fn event_handler(&mut self, event: &Event) -> Result<Self::EventResult>;
|
||||
fn active_state(&mut self) -> &mut ActiveState;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use ratatui::{symbols::block, widgets::Paragraph};
|
||||
use color_eyre::Result;
|
||||
use ratatui::widgets::Paragraph;
|
||||
|
||||
use crate::view::ActiveState;
|
||||
|
||||
@@ -14,6 +15,7 @@ pub struct ButtonComponent {
|
||||
active_state: ActiveState,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl ButtonComponent {
|
||||
pub fn text(mut self, text: String) -> Self {
|
||||
self.text = text;
|
||||
@@ -31,8 +33,8 @@ impl Component for ButtonComponent {
|
||||
}
|
||||
fn event_handler(
|
||||
&mut self,
|
||||
event: &crossterm::event::Event,
|
||||
) -> std::io::Result<Self::EventResult> {
|
||||
_event: &crossterm::event::Event,
|
||||
) -> Result<ButtonEvent> {
|
||||
Ok(ButtonEvent::Click)
|
||||
}
|
||||
fn active_state(&mut self) -> &mut ActiveState {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use std::io;
|
||||
|
||||
use color_eyre::Result;
|
||||
use crossterm::event::Event;
|
||||
use ratatui::widgets::{Paragraph, Widget};
|
||||
|
||||
@@ -19,7 +18,7 @@ impl Component for HelpComponent {
|
||||
let help = Paragraph::new("Temp").block(block);
|
||||
help
|
||||
}
|
||||
fn event_handler(&mut self, _event: &Event) -> io::Result<()> {
|
||||
fn event_handler(&mut self, _event: &Event) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
fn active_state(&mut self) -> &mut ActiveState {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use std::io;
|
||||
|
||||
use color_eyre::Result;
|
||||
use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
|
||||
use ratatui::{
|
||||
layout::{Position, Rect},
|
||||
@@ -11,6 +10,7 @@ use crate::view::ActiveState;
|
||||
|
||||
use super::{block::BlockComponent, Component};
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub enum InputEvent {
|
||||
Compelete,
|
||||
None,
|
||||
@@ -47,7 +47,7 @@ impl Component for InputComponent {
|
||||
input
|
||||
}
|
||||
|
||||
fn event_handler(&mut self, event: &Event) -> io::Result<InputEvent> {
|
||||
fn event_handler(&mut self, event: &Event) -> Result<InputEvent> {
|
||||
if !self.active_state.is_active() {
|
||||
return Ok(InputEvent::None);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use color_eyre::Result;
|
||||
use crossterm::{
|
||||
event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers},
|
||||
style::Color,
|
||||
@@ -26,8 +27,9 @@ pub struct ListComponent {
|
||||
}
|
||||
|
||||
impl ListComponent {
|
||||
pub fn add_item(&mut self, _item_keys: Vec<String>) {
|
||||
self.item_keys.extend(vec!["S".to_string()]);
|
||||
#[allow(dead_code)]
|
||||
pub fn add_item(&mut self, item_keys: Vec<String>) {
|
||||
self.item_keys.extend(item_keys);
|
||||
}
|
||||
pub fn name(mut self, name: String) -> Self {
|
||||
self.name = name;
|
||||
@@ -43,7 +45,7 @@ impl Default for ListComponent {
|
||||
fn default() -> Self {
|
||||
ListComponent {
|
||||
name: String::default(),
|
||||
item_keys: vec!["1".to_string(), "2".to_string(), "3".to_string()],
|
||||
item_keys: vec![],
|
||||
cursor: 0,
|
||||
selectable: false,
|
||||
active_state: Default::default(),
|
||||
@@ -74,7 +76,10 @@ impl Component for ListComponent {
|
||||
list
|
||||
}
|
||||
|
||||
fn event_handler(&mut self, event: &Event) -> std::io::Result<ListEvent> {
|
||||
fn event_handler(&mut self, event: &Event) -> Result<ListEvent> {
|
||||
if self.item_keys.is_empty() {
|
||||
return Ok(ListEvent::None);
|
||||
}
|
||||
if !self.active_state.is_active() {
|
||||
return Ok(ListEvent::None);
|
||||
}
|
||||
@@ -88,6 +93,7 @@ impl Component for ListComponent {
|
||||
use KeyCode::*;
|
||||
match code {
|
||||
Up => {
|
||||
if self.item_keys.len() == 0 {}
|
||||
self.cursor = if self.cursor == 0 {
|
||||
self.item_keys.len() - 1
|
||||
} else {
|
||||
@@ -112,6 +118,7 @@ impl Component for ListComponent {
|
||||
}
|
||||
Ok(ListEvent::None)
|
||||
}
|
||||
|
||||
fn active_state(&mut self) -> &mut ActiveState {
|
||||
&mut self.active_state
|
||||
}
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
use std::io;
|
||||
|
||||
use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind};
|
||||
use color_eyre::Result;
|
||||
use crossterm::event::Event;
|
||||
use ratatui::{
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
style::{Color, Style},
|
||||
widgets::{Block, BorderType, Borders},
|
||||
layout::{Constraint, Direction, Layout},
|
||||
Frame,
|
||||
};
|
||||
|
||||
use super::{
|
||||
component::{
|
||||
help::HelpComponent,
|
||||
input::{self, InputComponent, InputEvent},
|
||||
input::{InputComponent, InputEvent},
|
||||
list::{ListComponent, ListEvent},
|
||||
Component,
|
||||
},
|
||||
@@ -60,7 +57,7 @@ impl View for Home {
|
||||
self.setting.draw(frame);
|
||||
}
|
||||
|
||||
fn handle_event(&mut self, event: &Event) -> io::Result<()> {
|
||||
fn handle_event(&mut self, event: &Event) -> Result<()> {
|
||||
match self.input.event_handler(event) {
|
||||
Ok(InputEvent::None) => {}
|
||||
_ => {}
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
use std::io;
|
||||
|
||||
use ratatui::{
|
||||
layout::{Constraint, Layout, Rect},
|
||||
widgets::{Block, Clear},
|
||||
};
|
||||
use color_eyre::Result;
|
||||
use ratatui::layout::{Constraint, Layout, Rect};
|
||||
|
||||
use super::{
|
||||
center_rect,
|
||||
component::{
|
||||
block::BlockComponent,
|
||||
list::{ListComponent, ListEvent},
|
||||
Component,
|
||||
},
|
||||
@@ -47,7 +42,7 @@ impl View for SettingView {
|
||||
frame.render_widget(self.menu.widget(), layout[0]);
|
||||
}
|
||||
|
||||
fn handle_event(&mut self, event: &crossterm::event::Event) -> io::Result<()> {
|
||||
fn handle_event(&mut self, event: &crossterm::event::Event) -> Result<()> {
|
||||
match self.menu.event_handler(event) {
|
||||
Ok(ListEvent::Select(idx)) => {
|
||||
self.activate_state.set_active(false);
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
|
||||
Reference in New Issue
Block a user