newClient returns a Perkeep client for the server. The server may be: - blank, to use the default in the config file - an alias, to use that named alias in the config file - host:port - https?://host[:port][/path]
(server string, opts ...client.ClientOption)
| 45 | // - host:port |
| 46 | // - https?://host[:port][/path] |
| 47 | func newClient(server string, opts ...client.ClientOption) *client.Client { |
| 48 | if server == "" { |
| 49 | return client.NewOrFail(opts...) |
| 50 | } |
| 51 | cl := client.NewOrFail(append([]client.ClientOption{client.OptionServer(server)}, opts...)...) |
| 52 | if err := cl.SetupAuth(); err != nil { |
| 53 | log.Fatalf("Could not setup auth for connecting to %v: %v", server, err) |
| 54 | } |
| 55 | return cl |
| 56 | } |
| 57 | |
| 58 | var ( |
| 59 | flagServer = flag.String("server", "", "Server to search. "+serverFlagHelp) |
no test coverage detected