Skip to content

Commit

Permalink
cli: Update docs to use NewConfig
Browse files Browse the repository at this point in the history
Initializing Config structures directly does not properly initialize all
fields. The documentation has been updated to show that NewConfig is the
correct way to initalize a Config.
  • Loading branch information
sethterashima committed Dec 8, 2023
1 parent a0bb9a8 commit f920179
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ and OAuth tokens) in an OS-dependent credential store.
import flag
config := Config{Flags: FlagAll}
config, err := NewConfig(FlagAll)
if err != nil {
panic(err)
}
config.RegisterCommandLineFlags() // Adds command-line flags for private keys, OAuth, etc.
flag.Parse()
config.ReadFromEnvironment() // Fills in missing fields using environment variables
Expand All @@ -34,13 +37,13 @@ Alternatively, you can use a [Flag] mask to control what [Config] fields are pop
the examples below, config.Flags must be set before calling [flag.Parse] or
[Config.ReadFromEnvironment]:
config = Config{Flags: FlagOAuth | FlagPrivateKey | FlagVIN} // config.Connect() will use the Internet, not BLE.
config = Config{Flags: FlagBLE | FlagPrivateKey | FlagVIN} // config.Connect() will use BLE, not the Internet.
config = Config{Flags: FlagBLE | FlagVIN} // config.Connect() will create an unauthenticated vehicle connection.
config, err = NewConfig(FlagOAuth | FlagPrivateKey | FlagVIN) // config.Connect() will use the Internet, not BLE.
config, err = NewConfig(FlagBLE | FlagPrivateKey | FlagVIN) // config.Connect() will use BLE, not the Internet.
config, err = NewConfig(FlagBLE | FlagVIN) // config.Connect() will create an unauthenticated vehicle connection.
The last option will not attempt to load private keys when calling [Config.Connect], and therefore
will not result in an error if a private key is defined in the environment but cannot be loaded.
However, most [vehicle.Vehicle] commands do not work over unauathenticated connections.
However, most [vehicle.Vehicle] commands do not work over unauthenticated connections.
*/
package cli

Expand Down

0 comments on commit f920179

Please sign in to comment.