Enum python_launcher::cli::Action [−][src]
pub enum Action { Help(String, PathBuf), List(String), Execute { launcher_path: PathBuf, executable: PathBuf, args: Vec<String>, }, }
Expand description
Represents the possible outcomes based on CLI arguments.
Variants
The help string for the Python Launcher along with the path to a Python executable.
The executable path is so that it can be executed with -h
to append
Python’s own help output.
List(String)
A string listing all found executables on PATH
.
The string is formatted to be human-readable.
Details for executing a Python executable.
Fields of Execute
Implementations
Parses CLI arguments to determine what action should be taken.
The first argument – argv[0]
– is considered the path to the
Launcher itself (i.e. Action::Execute::launcher_path
).
The second argument – argv.get(1)
– is used to determine if/what
argument has been provided for the Launcher.
Launcher Arguments
-h
/--help
Returns Action::Help
.
The search for the Python executable to use is done using
crate::find_executable
with an RequestedVersion::Any
argument.
--list
Returns Action::List
.
The list of executable is gathered via crate::all_executables
.
Version Restriction
Returns the appropriate Action::Execute
instance for the requested
Python version.
crate::find_executable
is used to perform the search.
No Arguments for the Launcher
Returns an Action::Execute
instance.
As a first step, a check is done for an activated virtual environment
via the VIRTUAL_ENV
environment variable. If none is set, look for a
virtual environment in a directory named by DEFAULT_VENV_DIR
in the
current or any parent directories.
If no virtual environment is found, a shebang line is searched for in the first argument to the Python interpreter. If one is found then it is used to (potentially) restrict the requested version searched for.
The search for an interpreter proceeds using crate::find_executable
.
Errors
If -h
, --help
, or --list
are specified as the first argument but
there are other arguments, crate::Error::IllegalArgument
is returned.
If no executable could be found for Action::Help
or
Action::List
, crate::Error::NoExecutableFound
is returned.
Panics
- If a
writeln!
call fails. - If the current directory cannot be accessed.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Action
impl UnwindSafe for Action
Blanket Implementations
Mutably borrows from an owned value. Read more