Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
27a1ec6d2c
|
|||
|
1b1f9a31ed
|
|||
|
e5eddb39f7
|
|||
|
2000204250
|
|||
|
7912e9a516
|
|||
|
568d126fc2
|
|||
|
3ce4cbfad7
|
|||
|
36fcc84881
|
|||
|
c8b3a817f0
|
|||
|
f7737ea00d
|
|||
|
f56965abc2
|
|||
|
e7308bd5c6
|
|||
|
3077420db2
|
|||
|
73a0b87c31
|
|||
|
6fcf48ed61
|
|||
|
0b0ca06398
|
|||
|
98f02c1c08
|
|||
| 2754a3bb30 | |||
| e061d6dc6c | |||
| b45cfd3e0a |
243
Cargo.lock
generated
243
Cargo.lock
generated
@@ -1,10 +1,10 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ahab"
|
name = "ahab"
|
||||||
version = "0.3.0"
|
version = "0.4.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -14,24 +14,24 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstream"
|
name = "anstream"
|
||||||
version = "0.3.2"
|
version = "0.6.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
|
checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"anstyle-parse",
|
"anstyle-parse",
|
||||||
"anstyle-query",
|
"anstyle-query",
|
||||||
"anstyle-wincon",
|
"anstyle-wincon",
|
||||||
"colorchoice",
|
"colorchoice",
|
||||||
"is-terminal",
|
"is_terminal_polyfill",
|
||||||
"utf8parse",
|
"utf8parse",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle"
|
name = "anstyle"
|
||||||
version = "1.0.0"
|
version = "1.0.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d"
|
checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle-parse"
|
name = "anstyle-parse"
|
||||||
@@ -48,75 +48,61 @@ version = "1.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
|
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle-wincon"
|
name = "anstyle-wincon"
|
||||||
version = "1.0.1"
|
version = "3.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188"
|
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"windows-sys",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.71"
|
version = "1.0.91"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
|
checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bitflags"
|
|
||||||
version = "1.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cc"
|
|
||||||
version = "1.0.79"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.3.0"
|
version = "4.5.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc"
|
checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
"once_cell",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.3.0"
|
version = "4.5.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990"
|
checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"bitflags",
|
|
||||||
"clap_lex",
|
"clap_lex",
|
||||||
"strsim",
|
"strsim",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_complete"
|
name = "clap_complete"
|
||||||
version = "4.3.0"
|
version = "4.5.35"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a04ddfaacc3bc9e6ea67d024575fafc2a813027cf374b8f24f7bc233c6b6be12"
|
checksum = "07a13ab5b8cb13dbe35e68b83f6c12f9293b2f601797b71bc9f23befdb329feb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "4.3.0"
|
version = "4.5.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b"
|
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -126,9 +112,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "0.5.0"
|
version = "0.7.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
|
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "colorchoice"
|
name = "colorchoice"
|
||||||
@@ -142,85 +128,23 @@ version = "0.15.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "errno"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
|
|
||||||
dependencies = [
|
|
||||||
"errno-dragonfly",
|
|
||||||
"libc",
|
|
||||||
"windows-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "errno-dragonfly"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
version = "0.4.1"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "is_terminal_polyfill"
|
||||||
version = "0.3.1"
|
version = "1.70.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
|
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "io-lifetimes"
|
|
||||||
version = "1.0.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220"
|
|
||||||
dependencies = [
|
|
||||||
"hermit-abi",
|
|
||||||
"libc",
|
|
||||||
"windows-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "is-terminal"
|
|
||||||
version = "0.4.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f"
|
|
||||||
dependencies = [
|
|
||||||
"hermit-abi",
|
|
||||||
"io-lifetimes",
|
|
||||||
"rustix",
|
|
||||||
"windows-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc"
|
|
||||||
version = "0.2.144"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "linux-raw-sys"
|
|
||||||
version = "0.3.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "once_cell"
|
|
||||||
version = "1.17.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.58"
|
version = "1.0.89"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8"
|
checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
@@ -234,25 +158,11 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustix"
|
|
||||||
version = "0.37.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"errno",
|
|
||||||
"io-lifetimes",
|
|
||||||
"libc",
|
|
||||||
"linux-raw-sys",
|
|
||||||
"windows-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.10.0"
|
version = "0.11.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
@@ -283,7 +193,16 @@ version = "0.48.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-targets 0.48.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.59.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -292,13 +211,29 @@ version = "0.48.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
|
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows_aarch64_gnullvm",
|
"windows_aarch64_gnullvm 0.48.0",
|
||||||
"windows_aarch64_msvc",
|
"windows_aarch64_msvc 0.48.0",
|
||||||
"windows_i686_gnu",
|
"windows_i686_gnu 0.48.0",
|
||||||
"windows_i686_msvc",
|
"windows_i686_msvc 0.48.0",
|
||||||
"windows_x86_64_gnu",
|
"windows_x86_64_gnu 0.48.0",
|
||||||
"windows_x86_64_gnullvm",
|
"windows_x86_64_gnullvm 0.48.0",
|
||||||
"windows_x86_64_msvc",
|
"windows_x86_64_msvc 0.48.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_gnullvm 0.52.6",
|
||||||
|
"windows_aarch64_msvc 0.52.6",
|
||||||
|
"windows_i686_gnu 0.52.6",
|
||||||
|
"windows_i686_gnullvm",
|
||||||
|
"windows_i686_msvc 0.52.6",
|
||||||
|
"windows_x86_64_gnu 0.52.6",
|
||||||
|
"windows_x86_64_gnullvm 0.52.6",
|
||||||
|
"windows_x86_64_msvc 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -307,38 +242,86 @@ version = "0.48.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
|
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_msvc"
|
name = "windows_aarch64_msvc"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
|
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnu"
|
name = "windows_i686_gnu"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
|
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_msvc"
|
name = "windows_i686_msvc"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
|
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnu"
|
name = "windows_x86_64_gnu"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
|
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnullvm"
|
name = "windows_x86_64_gnullvm"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
|
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnullvm"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_msvc"
|
name = "windows_x86_64_msvc"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.52.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|||||||
13
Cargo.toml
13
Cargo.toml
@@ -2,16 +2,21 @@
|
|||||||
name = "ahab"
|
name = "ahab"
|
||||||
description = "docker cli wrapper"
|
description = "docker cli wrapper"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
version = "0.3.0"
|
version = "0.4.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Matej Janežič <janezic.mj@gmail.com>"]
|
authors = ["Matej Janežič <janezic.mj@gmail.com>"]
|
||||||
repository = "https://github.com/janezicmatej/ahab.git"
|
repository = "https://github.com/janezicmatej/ahab.git"
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.3.0", features = ["derive"] }
|
clap = { version = "4.5.20", features = ["derive"] }
|
||||||
clap_complete = "4.3.0"
|
# clap_complete = "4.5.35"
|
||||||
anyhow = "1.0.71"
|
anyhow = "1.0.91"
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
clap = { version = "4.5.20", features = ["derive"] }
|
||||||
|
clap_complete = "4.5.35"
|
||||||
|
|||||||
24
README.md
24
README.md
@@ -1 +1,25 @@
|
|||||||
# ahab
|
# ahab
|
||||||
|
|
||||||
|
## installing
|
||||||
|
|
||||||
|
You will need rust installed. Clone repo and run:
|
||||||
|
```bash
|
||||||
|
cargo install --path .
|
||||||
|
```
|
||||||
|
|
||||||
|
To print underlying commands build with `debug` flag.
|
||||||
|
```bash
|
||||||
|
cargo install --path . --debug
|
||||||
|
```
|
||||||
|
|
||||||
|
## shell completion
|
||||||
|
|
||||||
|
Completion files are generated **during build process** in `target/*/build/*/out/*`. Depending on your shell of choice move generated file to correct place in you file system.
|
||||||
|
|
||||||
|
## configuration
|
||||||
|
|
||||||
|
Currently `ahab` respects three environment variables.
|
||||||
|
|
||||||
|
- `COMPOSE_FILE`: control which docker-compose file is used - defaults to `docker/local/docker-compose.yaml`
|
||||||
|
- `AHAB_DJANGO_CONTAINER`: control which compose service is used for sending django commands - defaults to `django`
|
||||||
|
- `AHAB_POSTGRES_CONTAINER`: control which compose service is used for sending postgres commands - defaults to `db`
|
||||||
|
|||||||
22
build.rs
Normal file
22
build.rs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
use clap::{CommandFactory, ValueEnum};
|
||||||
|
use clap_complete::{generate_to, Shell};
|
||||||
|
use std::{env, io::Error};
|
||||||
|
|
||||||
|
include!("src/cli/mod.rs");
|
||||||
|
|
||||||
|
fn main() -> Result<(), Error> {
|
||||||
|
let outdir = match env::var_os("OUT_DIR") {
|
||||||
|
None => return Ok(()),
|
||||||
|
Some(outdir) => outdir,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut cmd = ahab::Ahab::command();
|
||||||
|
|
||||||
|
for shell in Shell::value_variants() {
|
||||||
|
let path = generate_to(*shell, &mut cmd, "ahab", &outdir)?;
|
||||||
|
|
||||||
|
println!("cargo:warning=completion file is generated: {path:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
use super::{Django, Docker, DockerCompose, Postgres};
|
use super::{Django, DockerCompose, Postgres};
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use clap_complete::Shell;
|
|
||||||
|
|
||||||
/// A program for interacting with various dockerized applications.
|
/// A program for interacting with various dockerized applications.
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
@@ -12,18 +11,6 @@ pub struct Ahab {
|
|||||||
|
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
pub enum Commands {
|
pub enum Commands {
|
||||||
/// Generate completion files
|
|
||||||
Completion {
|
|
||||||
#[arg(value_enum)]
|
|
||||||
shell: Shell,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Docker related subcommands
|
|
||||||
Docker {
|
|
||||||
#[command(subcommand)]
|
|
||||||
command: Docker,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Docker compose related subcommands
|
/// Docker compose related subcommands
|
||||||
Compose {
|
Compose {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
use clap::Parser;
|
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
|
||||||
pub enum Docker {
|
|
||||||
/// Stop all containers via `docker stop $(docker ps -q)`
|
|
||||||
StopAll,
|
|
||||||
}
|
|
||||||
@@ -5,12 +5,24 @@ use clap::Subcommand;
|
|||||||
/// Wraper for docker compose; autodiscover compose file and source .env file.
|
/// Wraper for docker compose; autodiscover compose file and source .env file.
|
||||||
#[derive(Subcommand, Debug)]
|
#[derive(Subcommand, Debug)]
|
||||||
pub enum DockerCompose {
|
pub enum DockerCompose {
|
||||||
|
/// Start bash session inside container
|
||||||
|
Bash,
|
||||||
|
|
||||||
/// Build containers.
|
/// Build containers.
|
||||||
Build,
|
Build,
|
||||||
|
|
||||||
/// Down containers.
|
/// Down containers.
|
||||||
Down,
|
Down,
|
||||||
|
|
||||||
|
/// Exec command inside container.
|
||||||
|
Exec {
|
||||||
|
#[arg(value_enum)]
|
||||||
|
rest: Vec<String>,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// Print services
|
||||||
|
Ps,
|
||||||
|
|
||||||
/// Stop, build and start containers.
|
/// Stop, build and start containers.
|
||||||
Rebuild,
|
Rebuild,
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
mod ahab;
|
mod ahab;
|
||||||
mod django;
|
mod django;
|
||||||
mod docker;
|
|
||||||
mod docker_compose;
|
mod docker_compose;
|
||||||
mod postgres;
|
mod postgres;
|
||||||
|
|
||||||
pub use ahab::{Ahab, Commands};
|
pub use ahab::{Ahab, Commands};
|
||||||
pub use django::Django;
|
pub use django::Django;
|
||||||
pub use docker::Docker;
|
|
||||||
pub use docker_compose::DockerCompose;
|
pub use docker_compose::DockerCompose;
|
||||||
pub use postgres::Postgres;
|
pub use postgres::Postgres;
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use std::{
|
use std::{
|
||||||
collections::VecDeque,
|
collections::VecDeque,
|
||||||
|
env,
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
fs::{File, OpenOptions},
|
fs::{File, OpenOptions},
|
||||||
|
os::unix::process::CommandExt,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
process::{Command, Stdio},
|
process::{Child, Command, Stdio},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::debug_println;
|
use crate::debug_eprintln;
|
||||||
|
|
||||||
pub struct Args(Vec<String>);
|
pub struct Args(Vec<String>);
|
||||||
|
|
||||||
@@ -24,6 +26,17 @@ impl From<&String> for Args {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<&[String]> for Args {
|
||||||
|
fn from(value: &[String]) -> Self {
|
||||||
|
Self(value.to_vec())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_compose_file() -> Result<String> {
|
||||||
|
let cf = env::var("COMPOSE_FILE")?;
|
||||||
|
Ok(cf)
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct CommandBuilder {
|
pub struct CommandBuilder {
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
@@ -45,7 +58,9 @@ impl CommandBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn docker_compose() -> Self {
|
pub fn docker_compose() -> Self {
|
||||||
Self::default().args("docker compose -f docker/local/docker-compose.yaml")
|
let cf =
|
||||||
|
get_compose_file().unwrap_or_else(|_| "docker/local/docker-compose.yaml".to_string());
|
||||||
|
Self::default().args("docker compose -f").args(&cf)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn args<T>(mut self, args: T) -> Self
|
pub fn args<T>(mut self, args: T) -> Self
|
||||||
@@ -56,8 +71,8 @@ impl CommandBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(self) -> Result<Command> {
|
pub fn build(self) -> Result<Command> {
|
||||||
debug_println!("\nran {self}\n");
|
debug_eprintln!("running `{self}`");
|
||||||
|
|
||||||
let (first, rest) = self.args.split_first().context("empty args")?;
|
let (first, rest) = self.args.split_first().context("empty args")?;
|
||||||
let mut command = Command::new(first);
|
let mut command = Command::new(first);
|
||||||
@@ -75,6 +90,10 @@ impl CommandBuilder {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn spawn(mut self) -> Result<(Child)> {
|
||||||
|
Ok(self.build()?.spawn()?)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn exec_redirect_stdout(mut self, stdio: Stdio) -> Result<()> {
|
pub fn exec_redirect_stdout(mut self, stdio: Stdio) -> Result<()> {
|
||||||
self.build()?.stdout(stdio).spawn()?.wait()?;
|
self.build()?.stdout(stdio).spawn()?.wait()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ pub mod scripts;
|
|||||||
|
|
||||||
// NOTE: stolen from https://docs.rs/debug_print/latest/debug_print/
|
// NOTE: stolen from https://docs.rs/debug_print/latest/debug_print/
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! debug_println {
|
macro_rules! debug_eprintln {
|
||||||
($($arg:tt)*) => (if ::std::cfg!(debug_assertions) { ::std::println!($($arg)*); })
|
($($arg:tt)*) => (#[cfg(debug_assertions)] eprintln!($($arg)*));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn safe_create_file(path: PathBuf) -> Result<File, std::io::Error> {
|
fn safe_create_file(path: PathBuf) -> Result<File, std::io::Error> {
|
||||||
|
|||||||
38
src/main.rs
38
src/main.rs
@@ -1,39 +1,30 @@
|
|||||||
use ahab::{cli, scripts};
|
use ahab::{cli, scripts};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{CommandFactory, Parser};
|
use clap::Parser;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
// always load dotenv on start
|
// always load dotenv on start
|
||||||
dotenvy::dotenv().ok();
|
dotenvy::dotenv().ok();
|
||||||
|
|
||||||
// TODO: (matej) some prints about project
|
|
||||||
// eg: DJANGO_SETTINGS_MODULE for django projects, used docker-compose, etc.
|
|
||||||
|
|
||||||
let args = cli::Ahab::parse();
|
let args = cli::Ahab::parse();
|
||||||
|
|
||||||
match args.command {
|
match args.command {
|
||||||
cli::Commands::Completion { shell } => {
|
cli::Commands::Compose { command } => {
|
||||||
clap_complete::generate(
|
eprintln!("DEPRECATION NOTICE: this is deprecated in favor of docker compose COMPOSE_FILE env");
|
||||||
shell,
|
match command {
|
||||||
&mut cli::Ahab::command(),
|
cli::DockerCompose::Bash => scripts::docker_compose::bash(),
|
||||||
"ahab",
|
|
||||||
&mut std::io::stdout(),
|
|
||||||
);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
cli::Commands::Docker { command } => match command {
|
|
||||||
cli::Docker::StopAll => scripts::docker::stop_all(),
|
|
||||||
},
|
|
||||||
cli::Commands::Compose { command } => match command {
|
|
||||||
cli::DockerCompose::Build => scripts::docker_compose::build(),
|
cli::DockerCompose::Build => scripts::docker_compose::build(),
|
||||||
cli::DockerCompose::Down => scripts::docker_compose::down(),
|
cli::DockerCompose::Down => scripts::docker_compose::down(),
|
||||||
|
cli::DockerCompose::Exec { rest } => scripts::docker_compose::exec(&rest),
|
||||||
|
cli::DockerCompose::Ps => scripts::docker_compose::ps(),
|
||||||
cli::DockerCompose::Rebuild => scripts::docker_compose::rebuild(),
|
cli::DockerCompose::Rebuild => scripts::docker_compose::rebuild(),
|
||||||
cli::DockerCompose::Restart => scripts::docker_compose::restart(),
|
cli::DockerCompose::Restart => scripts::docker_compose::restart(),
|
||||||
cli::DockerCompose::Start => scripts::docker_compose::start(None),
|
cli::DockerCompose::Start => scripts::docker_compose::start(None),
|
||||||
cli::DockerCompose::Stop => scripts::docker_compose::stop(),
|
cli::DockerCompose::Stop => scripts::docker_compose::stop(),
|
||||||
cli::DockerCompose::Up => scripts::docker_compose::up(),
|
cli::DockerCompose::Up => scripts::docker_compose::up(),
|
||||||
},
|
}
|
||||||
|
}
|
||||||
cli::Commands::Django { command } => match command {
|
cli::Commands::Django { command } => match command {
|
||||||
cli::Django::MakeCommand { app, name } => scripts::django::make_command(&app, &name),
|
cli::Django::MakeCommand { app, name } => scripts::django::make_command(&app, &name),
|
||||||
cli::Django::Makemigrations => scripts::django::makemigrations(),
|
cli::Django::Makemigrations => scripts::django::makemigrations(),
|
||||||
@@ -42,9 +33,12 @@ fn main() -> Result<()> {
|
|||||||
cli::Django::Shell => scripts::django::shell(),
|
cli::Django::Shell => scripts::django::shell(),
|
||||||
cli::Django::Test => scripts::django::test(),
|
cli::Django::Test => scripts::django::test(),
|
||||||
},
|
},
|
||||||
cli::Commands::Postgres { command } => match command {
|
cli::Commands::Postgres { command } => {
|
||||||
cli::Postgres::Import { path } => scripts::postgres::import(&path),
|
let db_container = std::env::var("AHAB_POSTGRES_CONTAINER").unwrap_or("db".to_string());
|
||||||
cli::Postgres::Dump { path } => scripts::postgres::dump(&path),
|
match command {
|
||||||
},
|
cli::Postgres::Import { path } => scripts::postgres::import(&db_container, &path),
|
||||||
|
cli::Postgres::Dump { path } => scripts::postgres::dump(&db_container, &path),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,6 @@ use anyhow::{anyhow, Result};
|
|||||||
use crate::command_builder::CommandBuilder;
|
use crate::command_builder::CommandBuilder;
|
||||||
use crate::{create_file, safe_create_file};
|
use crate::{create_file, safe_create_file};
|
||||||
|
|
||||||
fn get_django_settings_module() -> Result<String> {
|
|
||||||
let dsm = env::var("DJANGO_SETTINGS_MODULE")?;
|
|
||||||
println!("USING: {dsm}");
|
|
||||||
|
|
||||||
Ok(dsm)
|
|
||||||
}
|
|
||||||
|
|
||||||
const DEBUG_TEMPLATE: &str = r#"from django.core.management.base import BaseCommand
|
const DEBUG_TEMPLATE: &str = r#"from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
@@ -32,7 +25,7 @@ pub fn make_command(app: &PathBuf, name: &str) -> Result<()> {
|
|||||||
return Err(anyhow!("directory {app_name} does not exist"));
|
return Err(anyhow!("directory {app_name} does not exist"));
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("found app {app_name}");
|
eprintln!("found app {app_name}");
|
||||||
|
|
||||||
let management_dir = app_dir.join("management");
|
let management_dir = app_dir.join("management");
|
||||||
|
|
||||||
@@ -41,7 +34,7 @@ pub fn make_command(app: &PathBuf, name: &str) -> Result<()> {
|
|||||||
create_dir(&management_dir)?;
|
create_dir(&management_dir)?;
|
||||||
create_file(management_dir.join("__init__.py"))?;
|
create_file(management_dir.join("__init__.py"))?;
|
||||||
|
|
||||||
println!("created module {app_name}.management")
|
eprintln!("created module {app_name}.management")
|
||||||
};
|
};
|
||||||
|
|
||||||
let commands_dir = management_dir.join("commands");
|
let commands_dir = management_dir.join("commands");
|
||||||
@@ -51,20 +44,20 @@ pub fn make_command(app: &PathBuf, name: &str) -> Result<()> {
|
|||||||
create_dir(&commands_dir)?;
|
create_dir(&commands_dir)?;
|
||||||
create_file(commands_dir.join("__init__.py"))?;
|
create_file(commands_dir.join("__init__.py"))?;
|
||||||
|
|
||||||
println!("created module {app_name}.management.commands")
|
eprintln!("created module {app_name}.management.commands")
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut file = safe_create_file(commands_dir.join(format!("{name}.py")))?;
|
let mut file = safe_create_file(commands_dir.join(format!("{name}.py")))?;
|
||||||
file.write_all(DEBUG_TEMPLATE.as_bytes())?;
|
file.write_all(DEBUG_TEMPLATE.as_bytes())?;
|
||||||
|
|
||||||
println!("created command {app_name}.management.commands.{name}");
|
eprintln!("created command {app_name}.management.commands.{name}");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn manage(rest: &[String]) -> Result<()> {
|
pub fn manage(rest: &[String]) -> Result<()> {
|
||||||
let dsm = get_django_settings_module()?;
|
let container = env::var("AHAB_DJANGO_CONTAINER").unwrap_or("django".to_string());
|
||||||
let joined = rest.join(" ");
|
let joined = rest.join(" ");
|
||||||
let command = format!("exec appserver python manage.py {joined} --settings={dsm}");
|
let command = format!("run --rm {container} python manage.py {joined}");
|
||||||
CommandBuilder::docker_compose().args(&command).exec()
|
CommandBuilder::docker_compose().args(&command).exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,15 +11,29 @@ pub fn down() -> Result<()> {
|
|||||||
CommandBuilder::docker_compose().args("down").exec()
|
CommandBuilder::docker_compose().args("down").exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn exec(rest: &[String]) -> Result<()> {
|
||||||
|
let container = std::env::var("AHAB_DJANGO_CONTAINER").unwrap_or("django".to_string());
|
||||||
|
CommandBuilder::docker_compose()
|
||||||
|
.args("exec")
|
||||||
|
.args(&container)
|
||||||
|
.args(rest)
|
||||||
|
.exec()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ps() -> Result<()> {
|
||||||
|
CommandBuilder::docker_compose().args("ps").exec()
|
||||||
|
}
|
||||||
|
|
||||||
/// Start containers via `docker compose start`. Optionally pass containers to be started.
|
/// Start containers via `docker compose start`. Optionally pass containers to be started.
|
||||||
/// ```
|
/// ```
|
||||||
|
/// # use ahab::scripts::docker_compose::start;
|
||||||
/// start(None);
|
/// start(None);
|
||||||
/// ```
|
/// ```
|
||||||
/// is roughly the same as
|
/// is roughly the same as
|
||||||
/// `docker compose --env-file ./.env -f docker/local/docker-compose.yaml up start`
|
/// `docker compose --env-file ./.env -f docker/local/docker-compose.yaml up start`
|
||||||
pub fn start(containers: Option<&str>) -> Result<()> {
|
pub fn start(containers: Option<&str>) -> Result<()> {
|
||||||
let args = format!("start {}", containers.unwrap_or(""));
|
let args = format!("start {}", containers.unwrap_or(""));
|
||||||
CommandBuilder::docker_compose().args("start").exec()
|
CommandBuilder::docker_compose().args(&args).exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stop() -> Result<()> {
|
pub fn stop() -> Result<()> {
|
||||||
@@ -31,6 +45,10 @@ pub fn up() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// shortcuts
|
// shortcuts
|
||||||
|
pub fn bash() -> Result<()> {
|
||||||
|
exec(&["bash".to_string()])
|
||||||
|
}
|
||||||
|
|
||||||
pub fn rebuild() -> Result<()> {
|
pub fn rebuild() -> Result<()> {
|
||||||
stop()?;
|
stop()?;
|
||||||
build()?;
|
build()?;
|
||||||
|
|||||||
@@ -3,16 +3,18 @@ use std::{
|
|||||||
fs::File,
|
fs::File,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::Stdio,
|
process::Stdio,
|
||||||
|
thread,
|
||||||
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::docker_compose;
|
use super::docker_compose;
|
||||||
use crate::command_builder::CommandBuilder;
|
use crate::{command_builder::CommandBuilder, debug_eprintln};
|
||||||
|
|
||||||
fn get_containers() -> Result<[String; 2]> {
|
fn get_containers(container: &str) -> Result<[String; 2]> {
|
||||||
// get db container
|
// get db container
|
||||||
// FIX: we assume we are running db in service named "postgresbd"
|
|
||||||
let db_container = CommandBuilder::docker_compose()
|
let db_container = CommandBuilder::docker_compose()
|
||||||
.args("ps -q postgresdb")
|
.args("ps -q")
|
||||||
|
.args(container)
|
||||||
.exec_get_stdout()?
|
.exec_get_stdout()?
|
||||||
.trim()
|
.trim()
|
||||||
.to_string();
|
.to_string();
|
||||||
@@ -34,38 +36,52 @@ fn get_containers() -> Result<[String; 2]> {
|
|||||||
Ok([db_container, app_containers])
|
Ok([db_container, app_containers])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn import(file: &Path) -> Result<()> {
|
pub fn import(container: &str, file: &Path) -> Result<()> {
|
||||||
let [db_container, app_containers] = get_containers()?;
|
let [db_container, app_containers] = get_containers(container)?;
|
||||||
let dump_file = file.to_string_lossy();
|
let dump_file = file.to_string_lossy();
|
||||||
|
|
||||||
println!("stopping all containers");
|
eprintln!("stopping all containers");
|
||||||
docker_compose::stop()?;
|
docker_compose::stop()?;
|
||||||
|
|
||||||
println!("starting db container");
|
eprintln!("starting db container");
|
||||||
docker_compose::start(Some(&db_container))?;
|
docker_compose::start(Some(container))?;
|
||||||
|
|
||||||
println!("restoring database");
|
eprintln!("restoring database");
|
||||||
let commands = [
|
let commands = [
|
||||||
format!("cp {dump_file} {db_container}:/tmp/dbdump"),
|
format!("cp -L {dump_file} {db_container}:/tmp/dbdump"),
|
||||||
format!("exec {db_container} dropdb -U db db"),
|
format!("exec {db_container} dropdb -U db db"),
|
||||||
format!("exec {db_container} createdb -U db -E utf8 -T template0 db"),
|
format!("exec {db_container} createdb -U db -E utf8 -T template0 db"),
|
||||||
format!("exec {db_container} pg_restore -U db --dbname=db /tmp/dbdump"),
|
format!("exec {db_container} pg_restore -U db --dbname=db /tmp/dbdump"),
|
||||||
];
|
];
|
||||||
|
|
||||||
for command in commands {
|
for command in commands {
|
||||||
|
debug_eprintln!("waiting until pg_isready");
|
||||||
|
while !CommandBuilder::docker()
|
||||||
|
.args(&format!(
|
||||||
|
"exec {db_container} pg_isready -h {container} -p 5432 -U db",
|
||||||
|
))
|
||||||
|
.build()?
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.spawn()?
|
||||||
|
.wait()?
|
||||||
|
.success()
|
||||||
|
{
|
||||||
|
thread::sleep(Duration::from_secs(1));
|
||||||
|
}
|
||||||
CommandBuilder::docker().args(&command).exec()?;
|
CommandBuilder::docker().args(&command).exec()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("restarting containers");
|
eprintln!("restarting containers");
|
||||||
docker_compose::stop()?;
|
docker_compose::stop()?;
|
||||||
docker_compose::up()?;
|
docker_compose::up()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dump(file: &PathBuf) -> Result<()> {
|
pub fn dump(container: &str, file: &PathBuf) -> Result<()> {
|
||||||
let [db_container, _] = get_containers()?;
|
let [db_container, _] = get_containers(container)?;
|
||||||
|
|
||||||
println!("dumping to local file {}", file.to_string_lossy());
|
eprintln!("dumping to local file {}", file.to_string_lossy());
|
||||||
|
|
||||||
let file = File::create(file)?;
|
let file = File::create(file)?;
|
||||||
let stdout = Stdio::from(file);
|
let stdout = Stdio::from(file);
|
||||||
|
|||||||
Reference in New Issue
Block a user