MCPcopy Create free account
hub / github.com/auth0/auth0-cli / downloadQuickstart

Function downloadQuickstart

internal/cli/quickstarts.go:146–202  ·  view source on GitHub ↗
(cli *cli, inputs *qsInputs)

Source from the content-addressed store, hash-verified

144}
145
146func downloadQuickstart(cli *cli, inputs *qsInputs) func(cmd *cobra.Command, args []string) error {
147 return func(cmd *cobra.Command, args []string) error {
148 if err := inputs.fromArgs(cmd, args, cli); err != nil {
149 return fmt.Errorf("failed to parse command inputs: %w", err)
150 }
151
152 quickstartPath, pathExists, err := computeQuickstartPathFromClientName(inputs.Client.GetName())
153 if err != nil {
154 return fmt.Errorf("failed to compute the path where to download the quickstart sample: %w", err)
155 }
156
157 if pathExists && !cli.force {
158 message := fmt.Sprintf(
159 "%s %s already exists.\n Directory contents will be replaced. Are you sure you want to proceed? ",
160 ansi.Yellow("WARNING:"),
161 quickstartPath,
162 )
163 if confirmed := prompt.Confirm(message); !confirmed {
164 return nil
165 }
166 }
167
168 err = ansi.Waiting(func() error {
169 return inputs.Quickstart.Download(cmd.Context(), quickstartPath, inputs.Client)
170 })
171 if err != nil {
172 return fmt.Errorf("failed to download quickstart sample: %w", err)
173 }
174
175 cli.renderer.Infof("Quickstart sample successfully downloaded at %s", quickstartPath)
176
177 if err := promptDefaultURLs(cmd.Context(), cli, inputs.Client, inputs.QsTypeForClient, inputs.Stack); err != nil {
178 return err
179 }
180
181 qsSamplePath, err := inputs.Quickstart.SamplePath(quickstartPath)
182 if err != nil {
183 return err
184 }
185
186 readme, err := loadQuickstartSampleReadme(qsSamplePath)
187 if err != nil {
188 cli.renderer.Infof(inputs.Quickstart.DownloadInstructions)
189 } else {
190 cli.renderer.Markdown(readme)
191 }
192
193 relativeQSSamplePath, err := relativeQuickstartSamplePath(qsSamplePath)
194 if err != nil {
195 return err
196 }
197
198 cli.renderer.Infof("%s Start with `cd %s`", ansi.Faint("Hint:"), relativeQSSamplePath)
199
200 return nil
201 }
202}
203

Callers 1

downloadQuickstartCmdFunction · 0.85

Calls 15

YellowFunction · 0.92
ConfirmFunction · 0.92
WaitingFunction · 0.92
FaintFunction · 0.92
promptDefaultURLsFunction · 0.85
ErrorfMethod · 0.80
DownloadMethod · 0.80
InfofMethod · 0.80
SamplePathMethod · 0.80

Tested by

no test coverage detected