Functions for scraping names integrated enough to test (they don't work yet)

[?]
Jan 11, 2022, 3:31 AM
YCWYAX6K2DJKT7FO4IAYL6HJOIJLYFKAPGLFJ5XMYSYAS42LP3FQC

Dependencies

  • [2] PQ4BG3ZJ The web scrape functions
  • [3] KUANIPWF Add function for adding name to database
  • [4] AV73DYWQ Initial functions for using sqlite in async environment
  • [5] RNW6D777 Minor tidy
  • [6] HMOBTVJ4 Initialize crate and add expected dependencies

Change contents

  • edit in src/main.rs at line 1
    [3.49]
    [3.210]
    use clap::{Parser, Subcommand};
  • edit in src/main.rs at line 5
    [3.2010]
    [3.2010]
    use names_database::AsyncConnection;
    #[derive(Parser, Debug)]
    #[clap(about, version, author)]
    struct Args {
    database: String,
    #[clap(subcommand)]
    command: Commands,
    }
    #[derive(Debug,Subcommand)]
    enum Commands {
    Gather {
    #[clap(arg_enum)]
    gender: gather::Gender,
    }
    }
  • replacement in src/main.rs at line 26
    [3.283][3.283:301]()
    use std::env;
    [3.283]
    [2.0]
    let args = Args::parse();
  • replacement in src/main.rs at line 28
    [2.52][3.1325:1379](),[3.1325][3.1325:1379]()
    env::args().nth(1).ok_or(ArgsError::NoArgs)?,
    [2.52]
    [3.1379]
    args.database,
  • replacement in src/main.rs at line 31
    [3.1398][3.407:418](),[3.407][3.407:418](),[3.418][3.93:95](),[3.93][3.93:95](),[3.95][3.419:466]()
    Ok(())
    }
    #[derive(Debug)]
    enum ArgsError {
    NoArgs,
    [3.1398]
    [3.1399]
    args.command.run(&db).await
  • replacement in src/main.rs at line 34
    [3.1402][3.1402:1548]()
    impl std::fmt::Display for ArgsError {
    fn fmt(
    &self,
    f: &mut std::fmt::Formatter<'_>,
    ) -> Result<(), std::fmt::Error> {
    [3.1402]
    [3.1548]
    impl Commands {
    async fn run(&self, db: &AsyncConnection) -> Result<(), Box<dyn std::error::Error>> {
  • replacement in src/main.rs at line 37
    [3.1569][3.1569:1643]()
    ArgsError::NoArgs => write!(f, "Expected program arguments"),
    [3.1569]
    [3.1643]
    Self::Gather{ gender } => {
    let mut incoming = gather::all_names(*gender);
    while let Some(name) = incoming.recv().await {
    db.add_name(name).await?;
    }
    }
  • edit in src/main.rs at line 44
    [3.1653]
    [3.1653]
    Ok(())
  • edit in src/main.rs at line 47
    [3.468][3.468:509]()
    impl std::error::Error for ArgsError {}
  • edit in src/gather.rs at line 2
    [2.113]
    [2.113]
    use clap::ArgEnum;
  • replacement in src/gather.rs at line 4
    [2.114][2.114:152]()
    #[derive(PartialEq, Eq, Copy, Clone)]
    [2.114]
    [2.152]
    #[derive(ArgEnum, Debug, PartialEq, Eq, Copy, Clone)]
  • edit in Cargo.toml at line 9
    [3.309]
    [3.309]
    clap = { version = "3.0.6", features = ["derive"] }
  • edit in Cargo.lock at line 6
    [3.586]
    [3.586]
    name = "atty"
    version = "0.2.14"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
    dependencies = [
    "hermit-abi",
    "libc",
    "winapi",
    ]
    [[package]]
  • edit in Cargo.lock at line 63
    [3.2097]
    [3.2097]
    [[package]]
    name = "clap"
    version = "3.0.6"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "1957aa4a5fb388f0a0a73ce7556c5b42025b874e5cdc2c670775e346e97adec0"
    dependencies = [
    "atty",
    "bitflags",
    "clap_derive",
    "indexmap",
    "lazy_static",
    "os_str_bytes",
    "strsim",
    "termcolor",
    "textwrap",
    ]
  • edit in Cargo.lock at line 82
    [3.2110]
    [3.2110]
    name = "clap_derive"
    version = "3.0.6"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "517358c28fcef6607bf6f76108e02afad7e82297d132a6b846dcc1fc3efcd153"
    dependencies = [
    "heck",
    "proc-macro-error",
    "proc-macro2",
    "quote",
    "syn",
    ]
    [[package]]
  • edit in Cargo.lock at line 332
    [3.2192]
    [3.2192]
    name = "heck"
    version = "0.4.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
    [[package]]
  • edit in Cargo.lock at line 582
    [3.13992]
    [3.13992]
    "clap",
  • edit in Cargo.lock at line 675
    [3.15971]
    [3.15971]
    ]
    [[package]]
    name = "os_str_bytes"
    version = "6.0.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
    dependencies = [
    "memchr",
  • edit in Cargo.lock at line 802
    [3.18999]
    [3.18999]
    name = "proc-macro-error"
    version = "1.0.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
    dependencies = [
    "proc-macro-error-attr",
    "proc-macro2",
    "quote",
    "syn",
    "version_check",
    ]
    [[package]]
    name = "proc-macro-error-attr"
    version = "1.0.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
    dependencies = [
    "proc-macro2",
    "quote",
    "version_check",
    ]
    [[package]]
  • edit in Cargo.lock at line 1219
    [3.28514]
    [3.28514]
    name = "strsim"
    version = "0.10.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
    [[package]]
  • edit in Cargo.lock at line 1258
    [3.29279]
    [3.29279]
    ]
    [[package]]
    name = "termcolor"
    version = "1.1.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
    dependencies = [
    "winapi-util",
  • edit in Cargo.lock at line 1270
    [3.29294]
    [3.29294]
    name = "textwrap"
    version = "0.14.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
    [[package]]
  • edit in Cargo.lock at line 1431
    [3.33353]
    [3.33353]
    name = "version_check"
    version = "0.9.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
    [[package]]
  • edit in Cargo.lock at line 1549
    [3.36336]
    [3.36336]
    [[package]]
    name = "winapi-util"
    version = "0.1.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
    dependencies = [
    "winapi",
    ]