Switch everything to StructOpt (#277)

* Add types for Rojo's subcommands

* Flesh out CLI types

* Port everything to structopt instead of clap
This commit is contained in:
Lucien Greathouse 2019-12-12 14:30:47 -08:00 • committed by GitHub
parent 8b1e85fbb4
commit 47c7f63d75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 296 additions and 235 deletions

View file

@ -1,6 +1,5 @@
use std::{
io::{self, Write},
path::PathBuf,
sync::Arc,
};
@ -8,6 +7,7 @@ use failure::Fail;
use termcolor::{BufferWriter, Color, ColorChoice, ColorSpec, WriteColor};
use crate::{
cli::ServeCommand,
project::ProjectLoadError,
serve_session::ServeSession,
vfs::{RealFetcher, Vfs, WatchMode},
@ -16,12 +16,6 @@ use crate::{
const DEFAULT_PORT: u16 = 34872;
#[derive(Debug)]
pub struct ServeOptions {
pub fuzzy_project_path: PathBuf,
pub port: Option<u16>,
}
#[derive(Debug, Fail)]
pub enum ServeError {
#[fail(display = "Couldn't load project: {}", _0)]
@ -32,10 +26,10 @@ impl_from!(ServeError {
ProjectLoadError => ProjectLoad,
});
pub fn serve(options: &ServeOptions) -> Result<(), ServeError> {
pub fn serve(options: ServeCommand) -> Result<(), ServeError> {
let vfs = Vfs::new(RealFetcher::new(WatchMode::Enabled));
let session = Arc::new(ServeSession::new(vfs, &options.fuzzy_project_path));
let session = Arc::new(ServeSession::new(vfs, &options.project));
let port = options
.port