1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
use clap::ArgMatches; use client::Client; use config::Config; use errors::Result; use logs::fetch_stage; use repo::{trekker_name, branch}; use std::env::current_dir; use std::path::Path; use websocket; pub fn run<C: Client>(matches: &ArgMatches, config: &Config, client: &C, optional_path: Option<&Path>) -> Result<()> { let default_path = current_dir()?; let path = optional_path.unwrap_or(&default_path); let stage_name = matches.value_of("stage").expect("Expected required stage"); let trekker = match matches.value_of("trekker") { Some(trekker) => trekker.into(), None => trekker_name(path)?, }; let branch = match matches.value_of("branch") { Some(branch) => branch.into(), None => branch(path)?, }; let response = client.deploy(&trekker, &stage_name, &branch)?; debug!("{:?}", response); let stage = fetch_stage(stage_name, &trekker, client)?; let connection = websocket::client::build(stage.id, &config.token)?; websocket::client::run(connection)?; Ok(()) }