This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 337
/
main.rs
137 lines (128 loc) · 3.98 KB
/
main.rs
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#![cfg_attr(feature = "strict", deny(warnings))]
extern crate text_io;
extern crate tokio;
use std::env;
use wrangler::cli::{exec, Cli, Command};
use wrangler::installer;
use wrangler::terminal::message::{Message, StdErr};
use wrangler::terminal::{emoji, styles};
use wrangler::version::check_for_updates;
use anyhow::Result;
use structopt::StructOpt;
fn main() -> Result<()> {
env_logger::init();
StdErr::deprecation_warning(&format!(
r#"{} {} {}
The version of Wrangler you are using is now deprecated.
Please update to the latest version of wrangler to prevent critical errors.
If originally installed via npm, run `npm uninstall -g @cloudflare/wrangler && npm install -g wrangler` to update to the latest version.
If originally installed via cargo, run `cargo uninstall wrangler && npm install -g wrangler`
Docs migration guide: https://developers.cloudflare.com/workers/wrangler/migration/migrating-from-wrangler-1/#update-wrangler-version
"#,
emoji::NO_ENTRY,
styles::warning("DEPRECATED"),
emoji::NO_ENTRY,
));
if let Ok(me) = env::current_exe() {
// If we're actually running as the installer then execute our
// self-installation, otherwise just continue as usual.
if me
.file_stem()
.and_then(|s| s.to_str())
.expect("executable should have a filename")
.starts_with("wrangler-init")
{
installer::install()?;
}
}
run()?;
check_for_updates();
Ok(())
}
fn run() -> Result<()> {
let cli = Cli::from_args();
let cli_params = cli.clone();
match cli.command {
Command::Config { api_key, no_verify } => exec::configure(api_key, no_verify),
Command::Generate {
name,
site,
template,
target_type,
} => exec::generate(name, site, template, target_type),
Command::Init {
name,
site,
target_type,
} => exec::init(name, site, target_type),
Command::Build => exec::build(&cli_params),
Command::Preview {
method,
url,
body,
watch,
headless,
} => exec::preview(method, url, body, watch, headless, &cli_params),
Command::Dev {
host,
ip,
port,
local_protocol,
upstream_protocol,
inspect,
unauthenticated,
} => exec::dev(
host,
ip,
port,
local_protocol,
upstream_protocol,
&cli_params,
inspect,
unauthenticated,
),
Command::Whoami => exec::whoami(),
Command::Publish {
release,
output,
migration,
} => exec::publish(release, output, migration, &cli_params),
Command::Subdomain { name } => exec::subdomain(name, &cli_params),
Command::Route(route) => exec::route(route, &cli_params),
Command::Secret(secret) => exec::secret(secret, &cli_params),
Command::R2(r2) => exec::r2_bucket(r2, &cli_params),
Command::KvNamespace(namespace) => exec::kv_namespace(namespace, &cli_params),
Command::KvKey(key) => exec::kv_key(key, &cli_params),
Command::KvBulk(bulk) => exec::kv_bulk(bulk, &cli_params),
Command::Tail {
name,
url,
format,
once,
sampling_rate,
status,
method,
header,
ip_address,
search,
..
} => exec::tail(
name,
url,
format,
once,
sampling_rate,
status,
method,
header,
ip_address,
search,
&cli_params,
),
Command::Login {
scopes,
scopes_list,
} => exec::login(&scopes, scopes_list),
Command::Logout => exec::logout(),
}
}