mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-22 04:51:47 +00:00
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:
parent
8b1e85fbb4
commit
47c7f63d75
9 changed files with 296 additions and 235 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue