Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: pass request token as a flag instead of an argument #19

merged 1 commit into from Nov 17, 2018
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.


Just for now

Some generated files are not rendered by default. Learn more.

@@ -4,6 +4,7 @@ version = "0.1.0"
authors = ["0xazure <>"]

clap = "~2.32.0"
reqwest = "0.8.7"
serde = "1.0"
serde_json = "1.0"
@@ -1,12 +1,13 @@
extern crate chrono;
extern crate clap;
extern crate reqwest;
extern crate serde_derive;
extern crate serde_json;

use chrono::{DateTime, Utc};
use reqwest::header::{qitem, Accept, Authorization, Bearer, Link, RelationType, UserAgent};
use serde_derive::Deserialize;
use std::{env, error, fmt, mem};
use std::{error, fmt, mem};

pub struct Config {
@@ -15,19 +16,6 @@ pub struct Config {

impl Config {
pub fn new(mut args: env::Args) -> Result<Config, &'static str> {;

let username = match {
None => return Err("No username provided"),
Some(arg) => arg,

let token =;

Ok(Config { username, token })

fn url(self) -> Option<String> {
@@ -36,6 +24,15 @@ impl Config {

impl<'a> From<clap::ArgMatches<'a>> for Config {
fn from(matches: clap::ArgMatches) -> Self {
Config {
username: matches.value_of("USERNAME").unwrap().to_owned(),
token: matches.value_of("TOKEN").map(String::from),

struct ClientBuilder {
inner: reqwest::ClientBuilder,
@@ -1,13 +1,25 @@
extern crate clap;
extern crate supernova;

use std::{env, process};
use clap::{App, Arg, crate_name, crate_version};
use std::process;
use supernova::Config;

fn main() {
let config = Config::new(env::args()).unwrap_or_else(|err| {
println!("Problem parsing arguments: {}", err);
let config: Config = App::new(crate_name!())
.help("The user whose stars to collect")
.help("Sets the authentication token for requests to GitHub")

if let Err(e) = supernova::collect_stars(config) {
println!("Application error: {}", e);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.