Class: Gio::ApplicationCommandLine

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Overview

The GApplication::CommandLineClass-struct contains private data only.

Instance Method Summary collapse

Instance Method Details

#arguments=(arguments) ⇒ GLib::Variant

Returns arguments.

Parameters:

  • arguments (GLib::Variant)

Returns:

  • (GLib::Variant)

    arguments

#create_file_for_arg(arg) ⇒ Gio::File

Creates a #GFile corresponding to a filename that was given as part of the invocation of cmdline.

This differs from g_file_new_for_commandline_arg() in that it resolves relative pathnames using the current working directory of the invoking process rather than the local process.

Parameters:

  • arg (Gio::filename)

    an argument from cmdline

Returns:

#cwdGio::filename

Gets the working directory of the command line invocation. The string may contain non-utf8 data.

It is possible that the remote application did not send a working directory, so this may be nil.

The return value should not be modified or freed and is valid for as long as cmdline exists.

Returns:

  • (Gio::filename)

    the current directory, or nil

#environArray<Gio::filename>

Gets the contents of the ‘environ’ variable of the command line invocation, as would be returned by g_get_environ(), ie as a nil-terminated list of strings in the form ‘NAME=VALUE’. The strings may contain non-utf8 data.

The remote application usually does not send an environment. Use %G_APPLICATION_SEND_ENVIRONMENT to affect that. Even with this flag set it is possible that the environment is still not available (due to invocation messages from other applications).

The return value should not be modified or freed and is valid for as long as cmdline exists.

See g_application_command_line_getenv() if you are only interested in the value of a single environment variable.

Returns:

  • (Array<Gio::filename>)

    the environment strings, or nil if they were not sent

#exit_statusInteger

Gets the exit status of cmdline. See g_application_command_line_set_exit_status() for more information.

Returns:

  • (Integer)

    the exit status

#exit_status=(exit_status) ⇒ nil

Sets the exit status that will be used when the invoking process exits.

The return value of the #GApplication::command-line signal is passed to this function when the handler returns. This is the usual way of setting the exit status.

In the event that you want the remote invocation to continue running and want to decide on the exit status in the future, you can use this call. For the case of a remote invocation, the remote process will typically exit when the last reference is dropped on cmdline. The exit status of the remote process will be equal to the last value that was set with this function.

In the case that the commandline invocation is local, the situation is slightly more complicated. If the commandline invocation results in the mainloop running (ie: because the use-count of the application increased to a non-zero value) then the application is considered to have been ‘successful’ in a certain sense, and the exit status is always zero. If the application use count is zero, though, the exit status of the local GApplication::CommandLine is used.

Parameters:

  • exit_status (Integer)

    the exit status

Returns:

  • (nil)

#get_arguments(argc) ⇒ Array<Gio::filename>

Gets the list of arguments that was passed on the command line.

The strings in the array may contain non-UTF-8 data on UNIX (such as filenames or arguments given in the system locale) but are always in UTF-8 on Windows.

If you wish to use the return value with GOption::Context, you must use g_option_context_parse_strv().

The return value is nil-terminated and should be freed using g_strfreev().

Parameters:

  • argc (Integer)

    the length of the arguments array, or nil

Returns:

  • (Array<Gio::filename>)

    the string array containing the arguments (the argv)

#getenv(name) ⇒ String

Gets the value of a particular environment variable of the command line invocation, as would be returned by g_getenv(). The strings may contain non-utf8 data.

The remote application usually does not send an environment. Use %G_APPLICATION_SEND_ENVIRONMENT to affect that. Even with this flag set it is possible that the environment is still not available (due to invocation messages from other applications).

The return value should not be modified or freed and is valid for as long as cmdline exists.

Parameters:

  • name (Gio::filename)

    the environment variable to get

Returns:

  • (String)

    the value of the variable, or nil if unset or unsent

#is_remoteTrueClass

Determines if cmdline represents a remote invocation.

Returns:

  • (TrueClass)

    true if the invocation was remote

#is_remote=(is_remote) ⇒ TrueClass

Parameters:

  • is_remote (TrueClass)

Returns:

  • (TrueClass)

    is-remote

  • (TrueClass)

    is-remote

#is_remote?TrueClass

Returns is-remote.

Returns:

  • (TrueClass)

    is-remote

#options=(options) ⇒ GLib::Variant

Returns options.

Parameters:

  • options (GLib::Variant)

Returns:

  • (GLib::Variant)

    options

#options_dictGLib::VariantDict

Gets the options there were passed to g_application_command_line().

If you did not override local_command_line() then these are the same options that were parsed according to the GOption::Entrys added to the application with g_application_add_main_option_entries() and possibly modified from your GApplication::handle-local-options handler.

If no options were sent then an empty dictionary is returned so that you don’t need to check for nil.

Returns:

  • (GLib::VariantDict)

    a GVariant::Dict with the options

#platform_dataGLib::Variant

Gets the platform data associated with the invocation of cmdline.

This is a #GVariant dictionary containing information about the context in which the invocation occurred. It typically contains information like the current working directory and the startup notification ID.

For local invocation, it will be nil.

Returns:

  • (GLib::Variant)

    the platform data, or nil

#platform_data=(platform_data) ⇒ GLib::Variant

Returns platform-data.

Parameters:

  • platform_data (GLib::Variant)

Returns:

  • (GLib::Variant)

    platform-data

Formats a message and prints it using the stdout print handler in the invoking process.

If cmdline is a local invocation then this is exactly equivalent to g_print(). If cmdline is remote then this is equivalent to calling g_print() in the invoking process.

Parameters:

  • format (String)

    a printf-style format string

  • array (Array)

    arguments, as per format

Returns:

  • (nil)

#printerr(format, array) ⇒ nil

Formats a message and prints it using the stderr print handler in the invoking process.

If cmdline is a local invocation then this is exactly equivalent to g_printerr(). If cmdline is remote then this is equivalent to calling g_printerr() in the invoking process.

Parameters:

  • format (String)

    a printf-style format string

  • array (Array)

    arguments, as per format

Returns:

  • (nil)

#stdinGio::InputStream

Gets the stdin of the invoking process.

The GInput::Stream can be used to read data passed to the standard input of the invoking process. This doesn’t work on all platforms. Presently, it is only available on UNIX when using a DBus daemon capable of passing file descriptors. If stdin is not available then nil will be returned. In the future, support may be expanded to other platforms.

You must only call this function once per commandline invocation.

Returns: