@@ -209,12 +209,37 @@ $ miniflare worker.js --open # Opens http://localhost:8787
209209$ miniflare worker.js --open https://example.com # Opens https://example.com
210210```
211211
212+ ### REPL
213+
214+ Add the ` --repl ` flag to start an interactive REPL session. This behaves exactly
215+ like the [ Node.js REPL] ( https://nodejs.org/api/repl.html#repl ) , except you have
216+ access to Workers Runtime APIs instead. Any other Miniflare flag can be used
217+ too, with ` .env ` , ` package.json ` and ` wrangler.toml ` files automatically loaded.
218+ Specifying a script is optional when ` --repl ` is enabled, but may be required if
219+ you're using Durable Objects. If you're using an ES module format worker,
220+ bindings will be accessible via the ` env ` global variable.
221+
222+ ``` sh
223+ $ miniflare --repl --kv TEST_NAMESPACE
224+ > await new HTMLRewriter ().on(" p" , {
225+ ... element(e) {
226+ ..... e.setInnerContent(" new" );
227+ ..... }
228+ ... }).transform(new Response("<p>old</p>")).text ()
229+ ' <p>new</p>'
230+ > await env.TEST_NAMESPACE.put(" key" , " value" )
231+ undefined
232+ > await env.TEST_NAMESPACE.get(" key" )
233+ ' value'
234+ >
235+ ` ` `
236+
212237# ## Update Checker
213238
214239The CLI includes an automatic update checker that looks for new versions of
215240Miniflare once a day. As Cloudflare are always improving and tweaking workers,
216241you should aim to install these promptly for improved compatibility with the
217- real workers environment. You can disable this with the ` --no-update-check `
242+ real Workers environment. You can disable this with the ` --no-update-check`
218243flag.
219244
220245# # Reference
@@ -234,11 +259,13 @@ Core Options:
234259 --modules-rule Modules import rule [array:TYPE= GLOB]
235260 --compat-date Opt into backwards-incompatible changes from [string]
236261 --compat-flag Control specific backwards-incompatible changes [array]
262+ --usage-model Usage model (bundled by default) [string]
237263 -u, --upstream URL of upstream origin [string]
238264 -w, --watch Watch files for changes [boolean]
239265 -d, --debug Enable debug logging [boolean]
240266 -V, --verbose Enable verbose logging [boolean]
241267 --(no-)update-check Enable update checker (enabled by default) [boolean]
268+ --repl Enable interactive REPL [boolean]
242269 --root Path to resolve files relative to [string]
243270 --mount Mount additional named workers [array:NAME= PATH[@ENV]]
244271 --name Name of service [string]
@@ -247,6 +274,7 @@ Core Options:
247274 --global-timers Allow setting timers outside handlers [boolean]
248275 --global-random Allow secure random generation outside [boolean]
249276 handlers
277+ --actual-time Always return correct time from Date methods [boolean]
250278
251279HTTP Options:
252280 -H, --host Host for HTTP(S) server to listen on [string]
@@ -275,6 +303,10 @@ KV Options:
275303 -k , --kv KV namespace to bind [array]
276304 --kv-persist Persist KV data (to optional path) [boolean/string]
277305
306+ R2 Options:
307+ -r , --r2 R2 bucket to bind [array]
308+ --r2-persist Persist R2 data (to optional path) [boolean/string]
309+
278310Durable Objects Options:
279311 -o , --do Durable Object to bind [array:NAME= CLASS[@MOUNT]]
280312 --do-persist Persist Durable Object data (to [boolean/string]
@@ -323,6 +355,10 @@ kv_namespaces = [ # --kv
323355 { binding = " TEST_NAMESPACE" , id = " " , preview_id = " " }
324356]
325357
358+ r2_buckets = [ # --r2
359+ { binding = " BUCKET" , bucket_name = " " }
360+ ]
361+
326362[durable_objects]
327363bindings = [ # --do
328364 { name = " OBJECT" , class_name = " Object" }
@@ -366,6 +402,7 @@ watch = true # --watch
366402live_reload = true # --live-reload
367403env_path = " .env.test" # --env
368404kv_persist = true # --kv-persist
405+ r2_persist = true # --r2-persist
369406cache_persist = " ./cache" # --cache-persist
370407cache = false # --no-cache
371408durable_objects_persist = true # --do-persist
@@ -375,6 +412,7 @@ cf_fetch = "./cf.json" # --cf-fetch ./cf.json
375412cf_fetch = false # --no-cf-fetch
376413https = true # --https
377414https = " ./cert_cache" # --https ./cert_cache
415+ actual_time = true # --actual-time
378416global_async_io = true # --global-async-io
379417global_timers = true # --global-timers
380418global_random = true # --global-random
0 commit comments