Add some documentation to the CLI and the csv ingestion route
Some checks failed
Build and Publish Docker Container / build (push) Has been cancelled
Some checks failed
Build and Publish Docker Container / build (push) Has been cancelled
This commit is contained in:
parent
b37273cfbe
commit
3b2c1aeda0
@ -43,10 +43,12 @@ pub async fn monzo_batched_csv(
|
||||
Extension(db): Extension<DatabaseConnection>,
|
||||
multipart: Multipart,
|
||||
) -> Result<&'static str, AppError> {
|
||||
static CSV_MISSING_ERR_MSG: &'static str = "No CSV file provided. Expected a multipart request with a `csv` field containing the contents of the CSV.";
|
||||
|
||||
let csv = extract_csv(multipart)
|
||||
.await
|
||||
.map_err(|e| AppError::BadRequest(anyhow!(e)))
|
||||
.and_then(|csv| csv.ok_or(AppError::BadRequest(anyhow!("No CSV file provided"))))?;
|
||||
.and_then(|csv| csv.ok_or(AppError::BadRequest(anyhow!(CSV_MISSING_ERR_MSG))))?;
|
||||
|
||||
let csv = Cursor::new(csv);
|
||||
let mut csv = csv::Reader::from_reader(csv);
|
||||
|
||||
@ -18,6 +18,7 @@ use tracing::log::LevelFilter;
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
enum Commands {
|
||||
/// Manually run database migrations.
|
||||
Migrate {
|
||||
/// Number of migration steps to perform. If not provided, all migrations will be run.
|
||||
#[arg(long)]
|
||||
@ -28,8 +29,9 @@ enum Commands {
|
||||
down: bool,
|
||||
},
|
||||
|
||||
/// Start web app for to the google-sheets app script
|
||||
Serve {
|
||||
/// If we should perform migration on startup.
|
||||
/// If we should perform migration at startup.
|
||||
#[clap(short, long, env, default_value_t = true)]
|
||||
migrate: bool,
|
||||
|
||||
@ -38,12 +40,14 @@ enum Commands {
|
||||
addr: SocketAddr,
|
||||
},
|
||||
|
||||
/// Ingest a google-sheets CSV export into the database.
|
||||
Csv {
|
||||
/// The path to the CSV file to ingest.
|
||||
/// The path of the CSV file to ingest.
|
||||
csv_file: PathBuf,
|
||||
},
|
||||
}
|
||||
|
||||
/// Ingest and manage monzo transactions from the Monzo Plus auto-export feature
|
||||
#[derive(Debug, clap::Parser)]
|
||||
struct Cli {
|
||||
/// URL to PostgreSQL database.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user