<commit_before>#[macro_use]
extern crate error_chain;
extern crate reqwest;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json as json;
extern crate toml;
extern crate url;

mod config;
mod crates_io;
mod errors;
mod github;
mod lockfile;

use std::env;

use crates_io::Repository;
use errors::*;

quick_main!(|| -> Result<()> {
  let home_dir = env::home_dir().expect("Cannot get home directory");

  let config = config::read(&home_dir.join(".thank-you-stars.json"))
    .chain_err(|| "Save your configuration as `.thank-you-stars.json`")?;

  let lockfile = lockfile::read(&env::current_dir()?.join("Cargo.lock"))
    .chain_err(|| "Run `cargo install` before")?;

  for dependency in lockfile.root.dependencies {
    if dependency.is_registry() {
      let krate = crates_io::get(&dependency.crate_id())
        .chain_err(|| "Cannot get crate data from crates.io")?;

      if let Repository::GitHub(repository) = krate.repository() {
        match github::star(&config.token, &repository) {
          Ok(_) => println!("Starred! https://github.com/{}", &repository),
          Err(e) => println!("{}", e),
        }
      }
    }
  }

  Ok(())
});<commit_msg>Print errors to stderr instead of stdout<commit_after>#[macro_use]
extern crate error_chain;
extern crate reqwest;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json as json;
extern crate toml;
extern crate url;

mod config;
mod crates_io;
mod errors;
mod github;
mod lockfile;

use std::env;

use crates_io::Repository;
use errors::*;

quick_main!(|| -> Result<()> {
  let home_dir = env::home_dir().expect("Cannot get home directory");

  let config = config::read(&home_dir.join(".thank-you-stars.json"))
    .chain_err(|| "Save your configuration as `.thank-you-stars.json`")?;

  let lockfile = lockfile::read(&env::current_dir()?.join("Cargo.lock"))
    .chain_err(|| "Run `cargo install` before")?;

  for dependency in lockfile.root.dependencies {
    if dependency.is_registry() {
      let krate = crates_io::get(&dependency.crate_id())
        .chain_err(|| "Cannot get crate data from crates.io")?;

      if let Repository::GitHub(repository) = krate.repository() {
        match github::star(&config.token, &repository) {
          Ok(_) => println!("Starred! https://github.com/{}", &repository),
          Err(e) => eprintln!("{}", e.to_string()),
        }
      }
    }
  }

  Ok(())
});
{'fraction_non_alphanumeric': 0.16461412151067323, 'fraction_numerical': 0.0, 'mean_word_length': 3.9938524590163933, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1814778', 'n_tokens_mistral': 837, 'n_tokens_neox': 808, 'n_words': 202}