Initial yak shaving.
This commit is contained in:
commit
44eb261b95
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/target/
|
||||||
|
**/*.rs.bk
|
||||||
|
Cargo.lock
|
||||||
18
Cargo.toml
Normal file
18
Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[package]
|
||||||
|
name = "hammond"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Jordan Petridis <jordanpetridis@protonmail.com>"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
error-chain = "0.11.0"
|
||||||
|
structopt = "0.1.0"
|
||||||
|
structopt-derive = "0.1.0"
|
||||||
|
log = "0.3.8"
|
||||||
|
loggerv = "0.3.0"
|
||||||
|
reqwest = "0.7.3"
|
||||||
|
diesel = { version = "0.16.0", features = ["sqlite", "deprecated-time", "chrono"] }
|
||||||
|
diesel_codegen = { version = "0.16.0", features = ["sqlite"] }
|
||||||
|
time = "0.1.38"
|
||||||
|
xdg = "2.1.0"
|
||||||
|
lazy_static = "0.2.8"
|
||||||
|
chrono = "0.4.0"
|
||||||
2
migrations/2017-09-15-001128_init_schema/down.sql
Normal file
2
migrations/2017-09-15-001128_init_schema/down.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Drop Table Episode;
|
||||||
|
Drop Table Podcast;
|
||||||
23
migrations/2017-09-15-001128_init_schema/up.sql
Normal file
23
migrations/2017-09-15-001128_init_schema/up.sql
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
CREATE TABLE `Episode` (
|
||||||
|
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||||
|
`title` TEXT NOT NULL,
|
||||||
|
`desrciption` TEXT,
|
||||||
|
`uri` TEXT NOT NULL,
|
||||||
|
`local_uri` TEXT,
|
||||||
|
`thumbnail` TEXT,
|
||||||
|
`lenght` INTEGER,
|
||||||
|
`guid` TEXT,
|
||||||
|
`podcast_id` INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE `Podcast` (
|
||||||
|
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||||
|
`title` TEXT NOT NULL,
|
||||||
|
`uri` TEXT NOT NULL,
|
||||||
|
`link` TEXT,
|
||||||
|
`description` TEXT,
|
||||||
|
`last_modified` TEXT,
|
||||||
|
`http_etag` INTEGER,
|
||||||
|
`image_uri` TEXT,
|
||||||
|
`image_local` TEXT
|
||||||
|
);
|
||||||
22
src/cli.rs
Normal file
22
src/cli.rs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
use structopt::StructOpt;
|
||||||
|
use loggerv;
|
||||||
|
use errors::*;
|
||||||
|
|
||||||
|
#[derive(StructOpt, Debug)]
|
||||||
|
#[structopt(name = "example", about = "An example of StructOpt usage.")]
|
||||||
|
struct Opt {
|
||||||
|
/// Enable logging, use multiple `v`s to increase verbosity
|
||||||
|
#[structopt(short = "v", long = "verbose")]
|
||||||
|
verbosity: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run() -> Result<()> {
|
||||||
|
let args = Opt::from_args();
|
||||||
|
|
||||||
|
loggerv::init_with_verbosity(args.verbosity)?;
|
||||||
|
|
||||||
|
let foo = args;
|
||||||
|
info!("{:?}", foo);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
43
src/lib.rs
Normal file
43
src/lib.rs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#![recursion_limit = "1024"]
|
||||||
|
|
||||||
|
extern crate structopt;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate structopt_derive;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate error_chain;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate lazy_static;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate log;
|
||||||
|
extern crate loggerv;
|
||||||
|
extern crate reqwest;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate diesel;
|
||||||
|
|
||||||
|
// use diesel::prelude::*;
|
||||||
|
|
||||||
|
pub mod cli;
|
||||||
|
pub mod schema;
|
||||||
|
pub mod models;
|
||||||
|
|
||||||
|
pub mod errors {
|
||||||
|
|
||||||
|
use reqwest;
|
||||||
|
use std::io;
|
||||||
|
|
||||||
|
error_chain! {
|
||||||
|
foreign_links {
|
||||||
|
ReqError(reqwest::Error);
|
||||||
|
IoError(io::Error);
|
||||||
|
Log(::log::SetLoggerError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
assert_eq!(2 + 2, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/main.rs
Normal file
10
src/main.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#![recursion_limit = "1024"]
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate error_chain;
|
||||||
|
extern crate hammond;
|
||||||
|
|
||||||
|
|
||||||
|
use hammond::cli::run;
|
||||||
|
|
||||||
|
quick_main!(run);
|
||||||
0
src/models.rs
Normal file
0
src/models.rs
Normal file
27
src/schema.rs
Normal file
27
src/schema.rs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
table! {
|
||||||
|
episode (id) {
|
||||||
|
id -> Integer,
|
||||||
|
title -> Text,
|
||||||
|
desrciption -> Nullable<Text>,
|
||||||
|
uri -> Text,
|
||||||
|
local_uri -> Nullable<Text>,
|
||||||
|
thumbnail -> Nullable<Text>,
|
||||||
|
lenght -> Nullable<Integer>,
|
||||||
|
guid -> Nullable<Text>,
|
||||||
|
podcast_id -> Integer,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
table! {
|
||||||
|
podcast (id) {
|
||||||
|
id -> Integer,
|
||||||
|
title -> Text,
|
||||||
|
uri -> Text,
|
||||||
|
link -> Nullable<Text>,
|
||||||
|
description -> Nullable<Text>,
|
||||||
|
last_modified -> Nullable<Text>,
|
||||||
|
http_etag -> Nullable<Integer>,
|
||||||
|
image_uri -> Nullable<Text>,
|
||||||
|
image_local -> Nullable<Text>,
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user