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

cli: implement 'server of server' for a local web server #191014

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/shared.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Placeholders with the same ids are connected.
// Example:
"MSFT Copyright Header": {
"scope": "javascript,typescript,css",
"scope": "javascript,typescript,css,rust",
"prefix": [
"header",
"stub",
Expand Down
4 changes: 2 additions & 2 deletions cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ libc = "0.2.144"
tunnels = { git = "https://github.com/microsoft/dev-tunnels", rev = "2621784a9ad72aa39500372391332a14bad581a3", default-features = false, features = ["connections"] }
keyring = { version = "2.0.3", default-features = false, features = ["linux-secret-service-rt-tokio-crypto-openssl"] }
dialoguer = "0.10.4"
hyper = "0.14.26"
hyper = { version = "0.14.26", features = ["server", "http1", "runtime"] }
indicatif = "0.17.4"
tempfile = "3.5.0"
clap_lex = "0.5.0"
Expand Down
6 changes: 5 additions & 1 deletion cli/src/bin/code/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::process::Command;

use clap::Parser;
use cli::{
commands::{args, tunnels, update, version, CommandContext},
commands::{args, serve_web, tunnels, update, version, CommandContext},
constants::get_default_user_agent,
desktop, log,
state::LauncherPaths,
Expand Down Expand Up @@ -99,6 +99,10 @@ async fn main() -> Result<(), std::convert::Infallible> {
tunnels::command_shell(context!(), cs_args).await
}

Some(args::Commands::ServeWeb(sw_args)) => {
serve_web::serve_web(context!(), sw_args).await
}

Some(args::Commands::Tunnel(tunnel_args)) => match tunnel_args.subcommand {
Some(args::TunnelSubcommand::Prune) => tunnels::prune(context!()).await,
Some(args::TunnelSubcommand::Unregister) => tunnels::unregister(context!()).await,
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ pub mod args;
pub mod tunnels;
pub mod update;
pub mod version;
pub mod serve_web;
pub use context::CommandContext;
31 changes: 31 additions & 0 deletions cli/src/commands/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,42 @@ pub enum Commands {
/// Changes the version of the editor you're using.
Version(VersionArgs),

/// Runs a local web version of VS Code.
ServeWeb(ServeWebArgs),

/// Runs the control server on process stdin/stdout
#[clap(hide = true)]
CommandShell(CommandShellArgs),
}

#[derive(Args, Debug, Clone)]
pub struct ServeWebArgs {
/// Host to listen on, defaults to 'localhost'
#[clap(long)]
pub host: Option<String>,
/// Port to listen on. If 0 is passed a random free port is picked.
#[clap(long, default_value_t = 8000)]
pub port: u16,
/// A secret that must be included with all requests.
#[clap(long)]
pub connection_token: Option<String>,
/// Run without a connection token. Only use this if the connection is secured by other means.
#[clap(long)]
pub without_connection_token: bool,
/// If set, the user accepts the server license terms and the server will be started without a user prompt.
#[clap(long)]
pub accept_server_license_terms: bool,
/// Specifies the directory that server data is kept in.
#[clap(long)]
pub server_data_dir: Option<String>,
/// Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.
#[clap(long)]
pub user_data_dir: Option<String>,
/// Set the root path for extensions.
#[clap(long)]
pub extensions_dir: Option<String>,
}

#[derive(Args, Debug, Clone)]
pub struct CommandShellArgs {
/// Listen on a socket instead of stdin/stdout.
Expand Down
Loading