Documentation
¶
Index ¶
- Constants
- Variables
- func AddCommand(cfg *config.Config, args *AddCommandArguments) error
- func AddCommandInteractive(cfg *config.Config, api jsonapi.Connection) error
- func GetClient(cacert string) (http.Client, error)
- func GetHostAndToken(cfg *config.Config, hostname, token string) (string, string, error)
- func InitCommand() error
- func MigrateLegacyConfigFile(cfg *config.Config, api jsonapi.Connection) (string, error)
- func PullCommand(cfg *config.Config, api jsonapi.Connection, arguments *PullCommandArguments) error
- func PushCommand(cfg *config.Config, api jsonapi.Connection, args PushCommandArguments) error
- type AddCommandArguments
- type CreateAsyncDownloadArguments
- type PullCommandArguments
- type PushCommandArguments
Constants ¶
const PathSeparator = string(os.PathSeparator)
Variables ¶
var PromptMap = map[string]map[string]string{
"sourceFile": {
"text": `
The Transifex Client syncs files between your local directory and Transifex.
The mapping configuration between the two is stored in a file called .tx/config
in your current directory. For more information, visit
https://docs.transifex.com/client/config/.`,
"label": "What is the path of the source file?",
},
"fileFilter": {
"text": `
Next, we’ll need a path expression pointing to the location of the
translation files (whether they exist yet or not) associated with
the source file ‘{source_file}’. You should include <lang> as a
wildcard for the language code.`,
"label": "What is your path expression?",
},
}
var Version string
Functions ¶
func AddCommand ¶
func AddCommand( cfg *config.Config, args *AddCommandArguments, ) error
func AddCommandInteractive ¶
func AddCommandInteractive(cfg *config.Config, api jsonapi.Connection) error
func GetHostAndToken ¶
GetHostAndToken Function for getting the *final* API server hostname and token from a combination of environment variables, flags, config files and/or user input.
- 'cfg' is a 'config.Config' object that has already been loaded either based on the default configuration paths or ones that have been supplied by the user.
- 'hostname' is an override for the hostname to used that the user has maybe provided either as a flag or an environment variable.
- 'token' is an override for the API token to be used that the user has maybe provided either as a flag or an environment variable.
The logic for retrieving the final hostname and token is:
If the hostname flag/env variable is provided, use it as a section *key* in the root configuration file. For example, if the user provides 'aaa' and the root configuration file looks like this:
[aaa] rest_hostname = bbb
Then, the returned hostname will be 'bbb'.
If a matching host isn't found, then the returned hostname will be the provided value.
If the user didn't provide a hostname, try to find the "active host" based on both the local and root configuration. For example, if the local configuration looks like this:
[main] host = ccc
And the root configuration looks like this:
[aaa] rest_hostname = bbb
[ccc] rest_hostname = ddd
[eee] rest_hostname = fff
Then the "active host" will be the second one and the returned hostname will be 'ddd'.
If an active host cannot be found, then 'https://rest.api.transifex.com' will be returned.
3. If a token was provided by the user, simply return it.
- If a token wasn't provided, retrieve the token from either the "matching host" (see step 1) or the "active host" (see step 2). If a "matching" or "active" host wasn't found during the resolution of the hostname, the program will ask the user to provide a token. After the token is provided, it will be saved in the root configuration using the appropriate section key and hostname that were already retrieved.
func InitCommand ¶
func InitCommand() error
func MigrateLegacyConfigFile ¶
MigrateLegacyConfigFile Edits legacy config files so they contain all the necessary information to use the 3rd version of the API. Steps taken:
- Check for token setting. If not found check for API token in the old configuration. If not found generate one.
- Check for rest_hostname setting. If not found add it.
- Check the section keys are using the legacy format (`<project_slug>.<resource_slug>`) If yes find the organization for each section key and reformat the section key to conform to the new format (o:<organization_slug>:p:<project_slug>:r:<resource_slug>)
func PullCommand ¶
func PullCommand( cfg *config.Config, api jsonapi.Connection, arguments *PullCommandArguments, ) error
func PushCommand ¶
func PushCommand( cfg *config.Config, api jsonapi.Connection, args PushCommandArguments, ) error
Types ¶
type AddCommandArguments ¶
type CreateAsyncDownloadArguments ¶
type CreateAsyncDownloadArguments struct {
CommandArgs *PullCommandArguments
Project *jsonapi.Resource
//ResourceName string
CfgResource *config.Resource
}