Functions for scraping names integrated enough to test (they don't work yet)
[?]
Jan 11, 2022, 3:31 AM
YCWYAX6K2DJKT7FO4IAYL6HJOIJLYFKAPGLFJ5XMYSYAS42LP3FQCDependencies
- [2]
PQ4BG3ZJThe web scrape functions - [3]
KUANIPWFAdd function for adding name to database - [4]
AV73DYWQInitial functions for using sqlite in async environment - [5]
RNW6D777Minor tidy - [6]
HMOBTVJ4Initialize crate and add expected dependencies
Change contents
- edit in src/main.rs at line 1
use clap::{Parser, Subcommand}; - edit in src/main.rs at line 5
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
use std::env;let args = Args::parse(); - replacement in src/main.rs at line 28
env::args().nth(1).ok_or(ArgsError::NoArgs)?,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,args.command.run(&db).await - replacement in src/main.rs at line 34
impl std::fmt::Display for ArgsError {fn fmt(&self,f: &mut std::fmt::Formatter<'_>,) -> Result<(), std::fmt::Error> {impl Commands {async fn run(&self, db: &AsyncConnection) -> Result<(), Box<dyn std::error::Error>> { - replacement in src/main.rs at line 37
ArgsError::NoArgs => write!(f, "Expected program arguments"),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
Ok(()) - edit in src/main.rs at line 47
impl std::error::Error for ArgsError {} - edit in src/gather.rs at line 2
use clap::ArgEnum; - replacement in src/gather.rs at line 4
#[derive(PartialEq, Eq, Copy, Clone)]#[derive(ArgEnum, Debug, PartialEq, Eq, Copy, Clone)] - edit in Cargo.toml at line 9
clap = { version = "3.0.6", features = ["derive"] } - edit in Cargo.lock at line 6
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
[[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
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
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
"clap", - edit in Cargo.lock at line 675
][[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
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
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
][[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
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
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
[[package]]name = "winapi-util"version = "0.1.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"dependencies = ["winapi",]