Expand description
Launch arguments — the typed parameters the app was started with.
This is the Cranpose equivalent of reading intent.extras in a Jetpack
Compose activity. A Cranpose app on Android is a NativeActivity, so it
sees neither the environment of the shell that ran am start nor, until
now, the launching Intent; debug and instrumentation flags read through
std::env::var silently return nothing on device. launch_args gives
the same values back, typed, on every platform.
Where the values come from:
- Android — the extras of the launching
Intent, pushed in by thecranpose::androidbackend (adb shell am start ... --ez flag true).onNewIntentreplaces the snapshot, exactly assetIntentreplaces whatgetIntent().getExtras()returns for a Compose activity. - Desktop and iOS — the process command line (the built-in default
below). Command line rather than environment because argv is the launch
payload: it is per-launch, it is not inherited by child processes, and it
is what the platform tooling already passes —
xcrun simctl launch,XCUIApplication().launchArguments, and a plain shell invocation all set argv, while an exported environment variable leaks into every later process in that session and cannot be replaced on relaunch. - Web — nothing by default; a shell may install the query string.
Values keep the type the platform delivered (--ez/--ei/--el/--ef/
--es on Android), and text values are parsed on demand, so an argument
written as text on the command line still reads back as a number.
use cranpose_services::launch_args;
let args = launch_args();
if args.is_debuggable() && args.boolean("ob_debug").unwrap_or(false) {
let level = args.int("ob_level").unwrap_or(0);
let seed = args.long("ob_seed").unwrap_or(0);
let time_scale = args.float("ob_time_scale").unwrap_or(1.0);
let screen = args.string("ob_screen").unwrap_or("");
let _ = (level, seed, time_scale, screen);
}Structs§
- Launch
Args - The launch arguments the app was started with.
Enums§
- Launch
ArgValue - One launch-argument value, in the type the platform delivered it.
Functions§
- Provide
Launch Args - Provides launch arguments to
content. - clear_
platform_ launch_ args - Removes any platform-reported launch arguments (tests and teardown).
- isDebuggable
- Whether the OS considers this build debuggable, read from composition.
- is_
debuggable - Whether the OS considers this build debuggable — see
LaunchArgs::is_debuggable. - launch_
args - The launch arguments this app was started with.
- launch_
args_ from_ command_ line - Parses
--name=value(text) and bare--name(true) out of a command line. - local_
launch_ args - The composition local carrying the launch arguments.
- set_
platform_ launch_ args - Installs the launch arguments reported by the platform, replacing any previous snapshot.
Type Aliases§
- Launch
Args Ref - Shared handle to a
LaunchArgssnapshot.