Command line interface

The goldfinchsong command

Once you’ve installed goldfinchsong into your active Python environment, you have the goldfinchsong command at your disposal. This command chooses a random image from your local image library, constructs a status text, and posts it with the credentials in your configuration file.

There are three option flags available for the command.

--action (default: post)

The action the script should take. The post action uploads a tweet.

--conf (default: goldfinchsong.ini)

The location of the configuration file.

--images (default: None)

The location of the image directory. You can also configure this in the ini file, but the command line value overrides (i.e. takes precedence) the ini settings. If there’s no value passed to the command or found in the configuration file, then ‘images’ is used as the default directory location.

Module functions

goldfinchsong.cli.get_image_directory(command_line_input, active_configuration)

Provides path to image directory.

Parameters:
  • command_line_input (str | None) – A path that may optionally be submitted by user. A string or None are expected types.
  • active_configuration (dict) – Active configuration options.
Returns:

A path to the image directory. Default: images

Return type:

str

goldfinchsong.cli.parse_configuration(config_parser)

Extracts credential and text conversion information.

Parameters:config_parser – A ConfigParser from the standard library loaded with local configuration file.
Returns:The returned dict contains twitter credentials, any text conversions, and any image and/or log configuration information made available.
Return type:dict
goldfinchsong.cli.run(action='post', conf='goldfinchsong.ini', images=None)

Uploads an image tweet.

The Manager class does the actual work; this function contributes logic for extracting configuration settings and creating a TinyDB instance.

Parameters:
  • action (str) – An action name.
  • conf (str) – File path for a configuration file. By default, this function looks for goldfinchsong.ini under the directory from which the user executes the function.
  • images (str) – File path to a directory with images that will be uploaded by tweets.