MCPcopy Create free account
hub / github.com/plexdrive/plexdrive / Create

Function Create

config/config.go:30–62  ·  view source on GitHub ↗

Create creates the configuration by requesting from stdin

(configPath string)

Source from the content-addressed store, hash-verified

28
29// Create creates the configuration by requesting from stdin
30func Create(configPath string) (*Config, error) {
31 var config Config
32 fmt.Println("1. Please go to https://console.developers.google.com/")
33 fmt.Println("2. Create a new project")
34 fmt.Println("3. Go to library and activate the Google Drive API")
35 fmt.Println("4. Go to credentials and create an OAuth client ID")
36 fmt.Println("5. Set the application type to 'other'")
37 fmt.Println("6. Specify some name and click create")
38 fmt.Printf("7. Enter your generated client ID: ")
39
40 if _, err := fmt.Scan(&config.ClientID); err != nil {
41 Log.Debugf("%v", err)
42 return nil, fmt.Errorf("Unable to read client id")
43 }
44 fmt.Printf("8. Enter your generated client secret: ")
45 if _, err := fmt.Scan(&config.ClientSecret); err != nil {
46 Log.Debugf("%v", err)
47 return nil, fmt.Errorf("Unable to read client secret")
48 }
49
50 configJSON, err := json.Marshal(&config)
51 if nil != err {
52 Log.Debugf("%v", err)
53 return nil, fmt.Errorf("Could not generate config.json content")
54 }
55
56 if err := ioutil.WriteFile(configPath, configJSON, 0766); nil != err {
57 Log.Debugf("%v", err)
58 return nil, fmt.Errorf("Could not generate config.json file")
59 }
60
61 return &config, nil
62}

Callers 1

mainFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected