diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..eca274a --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,465 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" + +[[package]] +name = "beslib" +version = "0.3.0" +dependencies = [ + "anyhow", + "crc", + "serialport", + "thiserror", +] + +[[package]] +name = "bestool" +version = "0.3.0" +dependencies = [ + "anyhow", + "beslib", + "clap", + "crc", + "serialport", + "thiserror", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "crc" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "io-kit-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4769cb30e5dcf1710fc6730d3e94f78c47723a014a567de385e113c737394640" +dependencies = [ + "core-foundation-sys", + "mach2", +] + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "libudev" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b324152da65df7bb95acfcaab55e3097ceaab02fb19b228a9eb74d55f135e0" +dependencies = [ + "libc", + "libudev-sys", +] + +[[package]] +name = "libudev-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serialport" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f5a15d0be940df84846264b09b51b10b931fb2f275becb80934e3568a016828" +dependencies = [ + "bitflags 2.4.2", + "cfg-if", + "core-foundation-sys", + "io-kit-sys", + "libudev", + "mach2", + "nix", + "regex", + "scopeguard", + "unescaper", + "winapi", +] + +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + +[[package]] +name = "syn" +version = "2.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unescaper" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0adf6ad32eb5b3cadff915f7b770faaac8f7ff0476633aa29eb0d9584d889d34" +dependencies = [ + "thiserror", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +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.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..f676d72 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,26 @@ +[workspace] +resolver = "2" +members = [ + "src/beslib", + "src/bestool", +] + +[workspace.package] +authors = ["Ben V. Brown <>", "Dom Rodriguez "] +edition = "2021" +homepage = "https://github.com/Ralim/bestool" +readme = "/README.md" +repository = "https://github.com/Ralim/bestool.git" +rust-version = "1.67.0" +version = "0.3.0" + +[workspace.dependencies] +anyhow = "1.0.79" +clap = { version = "4.5.1", features = ["derive"] } +crc = "3.0.1" +serde = { version = "1.0.196", features = ["derive"] } +serde_json = "1.0.113" +serialport = "4.3.0" +thiserror = "1.0" +tracing = "0.1.40" +tracing-subscriber = "0.3.18" diff --git a/src/beslib/Cargo.toml b/src/beslib/Cargo.toml new file mode 100644 index 0000000..c7a63cb --- /dev/null +++ b/src/beslib/Cargo.toml @@ -0,0 +1,16 @@ +[package] +authors = { workspace = true } +description = "Support library for `bestool`; a command-line utility for BES2300 chips." +edition = { workspace = true } +homepage = { workspace = true } +# license = { workspace = true } # TODO: Specify license with REUSE. +name = "beslib" +repository = { workspace = true } +rust-version = { workspace = true } +version = { workspace = true } + +[dependencies] +anyhow = { workspace = true } +crc = { workspace = true } +serialport = { workspace = true } +thiserror = { workspace = true } diff --git a/src/beslib/src/boot/enums.rs b/src/beslib/src/boot/enums.rs new file mode 100644 index 0000000..2352c0a --- /dev/null +++ b/src/beslib/src/boot/enums.rs @@ -0,0 +1,127 @@ +#![allow(non_camel_case_types)] + +#[derive(Debug, Default, PartialEq, Eq)] +pub enum MsgTypeKind { + TYPE_SYS = 0x00, + TYPE_READ = 0x01, + TYPE_WRITE = 0x02, + TYPE_BULK_READ = 0x03, + TYPE_EXT_WRITE = 0x04, + TYPE_BULK_WRITE_START = 0x05, + TYPE_BULK_WRITE_DATA = 0x06, + TYPE_NOTIF = 0x10, + TYPE_SYNC = 0x50, + TYPE_SIG_INFO = 0x51, + TYPE_SIG = 0x52, + TYPE_CODE_INFO = 0x53, + TYPE_CODE = 0x54, + TYPE_RUN = 0x55, + TYPE_SECTOR_SIZE = 0x60, + TYPE_ERASE_BURN_START = 0x61, + TYPE_ERASE_BURN_DATA = 0x62, + TYPE_OBSOLETED_63 = 0x63, + TYPE_OBSOLETED_64 = 0x64, + TYPE_FLASH_CMD = 0x65, + TYPE_GET_SECTOR_INFO = 0x66, + TYPE_SEC_REG_ERASE_BURN_START = 0x67, + TYPE_SEC_REG_ERASE_BURN_DATA = 0x68, + + // Extended types + TYPE_PROD_TEST = 0x81, + TYPE_RUNTIME_CMD = 0x82, + TYPE_BT_CALIB_CMD = 0x83, + TYPE_PROTO_EL = 0xA0, + + TYPE_INVALID = 0xFF, + + #[default] + Unknown, +} + +#[derive(Debug, Default, PartialEq, Eq)] +pub enum SysCmdKind { + SYS_CMD_REBOOT = 0xF1, + SYS_CMD_SHUTDOWN = 0xF2, + SYS_CMD_FLASH_BOOT = 0xF3, + SYS_CMD_SET_BOOTMODE = 0xE1, + SYS_CMD_CLR_BOOTMODE = 0xE2, + SYS_CMD_GET_BOOTMODE = 0xE3, + SYS_CMD_SET_DLD_RATE = 0xD1, + + #[default] + Unknown, +} + +#[derive(Debug, Default, PartialEq, Eq)] +pub enum ErrCodeKind { + ERR_NONE = 0x00, + ERR_LEN = 0x01, + ERR_CHECKSUM = 0x02, + ERR_NOT_SYNC = 0x03, + ERR_NOT_SEC = 0x04, + ERR_SYNC_WORD = 0x05, + ERR_SYS_CMD = 0x06, + ERR_DATA_ADDR = 0x07, + ERR_DATA_LEN = 0x08, + ERR_ACCESS_RIGHT = 0x09, + + ERR_TYPE_INVALID = 0x0F, + + ERR_BOOT_OK = 0x10, + ERR_BOOT_MAGIC = 0x11, + ERR_BOOT_SEC = 0x12, + ERR_BOOT_HASH_TYPE = 0x13, + ERR_BOOT_KEY_TYPE = 0x14, + ERR_BOOT_KEY_LEN = 0x15, + ERR_BOOT_SIG_LEN = 0x16, + ERR_BOOT_SIG = 0x17, + ERR_BOOT_CRC = 0x18, + ERR_BOOT_LEN = 0x19, + ERR_SIG_CODE_SIZE = 0x1A, + ERR_SIG_SIG_LEN = 0x1B, + ERR_SIG_INFO_MISSING = 0x1C, + ERR_BOOT_KEY_ID = 0x1D, + ERR_BOOT_HASH = 0x1E, + + ERR_CODE_OK = 0x20, + ERR_BOOT_MISSING = 0x21, + ERR_CODE_SIZE_SIG = 0x22, + ERR_CODE_ADDR_SIZE = 0x23, + ERR_CODE_INFO_MISSING = 0x24, + ERR_CODE_CRC = 0x25, + ERR_CODE_SIG = 0x26, + + ERR_CODE_MISSING = 0x31, + ERR_VERSION = 0x32, + + ERR_BURN_OK = 0x60, + ERR_SECTOR_SIZE = 0x61, + ERR_SECTOR_SEQ_OVERFLOW = 0x62, + ERR_BURN_INFO_MISSING = 0x63, + ERR_SECTOR_DATA_LEN = 0x64, + ERR_SECTOR_DATA_CRC = 0x65, + ERR_SECTOR_SEQ = 0x66, + ERR_ERASE_FLSH = 0x67, + ERR_BURN_FLSH = 0x68, + ERR_VERIFY_FLSH = 0x69, + ERR_FLASH_CMD = 0x6A, + + ERR_TYPE_MISMATCHED = 0xE1, + ERR_SEQ_MISMATCHED = 0xE2, + ERR_BUF_TOO_SMALL = 0xE3, + + ERR_INTERNAL = 0xFF, + + #[default] + Unknown, +} + +#[derive(Debug, Default, PartialEq, Eq)] +pub enum ParseState { + PARSE_HEADER, + PARSE_DATA, + PARSE_EXTRA, + + #[default] + Unknown, +} diff --git a/src/beslib/src/lib.rs b/src/beslib/src/lib.rs new file mode 100644 index 0000000..8be9ea3 --- /dev/null +++ b/src/beslib/src/lib.rs @@ -0,0 +1,9 @@ +pub mod boot { + pub mod enums; + pub mod consts { + pub const BOOT_MAGIC_NUMBER: u32 = 0xBE57EC1C; + pub const BOOT_HASH_TYPE_MD5: u8 = 1; + } + pub const MAX_READ_DATA_LEN: u16 = 16; + pub const MAX_WRITE_DATA_LEN: u16 = 16; +} diff --git a/src/bestool/Cargo.toml b/src/bestool/Cargo.toml new file mode 100644 index 0000000..97a3fbc --- /dev/null +++ b/src/bestool/Cargo.toml @@ -0,0 +1,18 @@ +[package] +authors = { workspace = true } +description = "Command-line utility for BES2300 chips." +edition = { workspace = true } +homepage = { workspace = true } +# license = { workspace = true } # TODO: Specify license with REUSE. +name = "bestool" +repository = { workspace = true } +rust-version = { workspace = true } +version = { workspace = true } + +[dependencies] +anyhow = { workspace = true } +beslib = { path = "../beslib" } +clap = { workspace = true } +crc = { workspace = true } +serialport = { workspace = true } +thiserror = { workspace = true } diff --git a/src/bestool/src/command/mod.rs b/src/bestool/src/command/mod.rs new file mode 100644 index 0000000..985b636 --- /dev/null +++ b/src/bestool/src/command/mod.rs @@ -0,0 +1,20 @@ +use clap::Subcommand; +use anyhow::Result; + +#[derive(Subcommand)] +#[command(infer_subcommands = true)] +pub(crate) enum BestoolCmd { + Flash, + Read, + SerialMonitor, +} + +impl BestoolCmd { + pub(crate) fn run(self) -> Result<()> { + match self { + Self::Flash => unimplemented!(), + Self::Read => unimplemented!(), + Self::SerialMonitor => unimplemented!(), + } + } +} diff --git a/src/bestool/src/main.rs b/src/bestool/src/main.rs new file mode 100644 index 0000000..2dfc92e --- /dev/null +++ b/src/bestool/src/main.rs @@ -0,0 +1,39 @@ +#![warn(clippy::pedantic, clippy::nursery)] + +use clap::Parser; +mod command; +use anyhow::Result; +use command::BestoolCmd; + +pub(crate) const VER: &'static str = env!("CARGO_PKG_VERSION"); + +static HELP_TEMPLATE: &'static str = "\ +{before-help}{name} {version} +{author} +{about} + +{usage-heading} + {usage} + +{all-args}{after-help}"; + +#[derive(Parser)] +#[command( + author = "Ben V. Brown <>", + version = VER, + help_template = HELP_TEMPLATE, +)] +struct Bestool { + #[command(subcommand)] + bestool: BestoolCmd, +} + +impl Bestool { + fn run(self) -> Result<()> { + self.bestool.run() + } +} + +fn main() -> Result<()> { + Ok(Bestool::parse().run()?) +}