Skip to content

Commit 5e75119

Browse files
committed
remove no-python option for creating app
1 parent 12a78db commit 5e75119

File tree

10 files changed

+11
-101
lines changed

10 files changed

+11
-101
lines changed

cmd/arduino-app-cli/app/new.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func newCreateCmd(cfg config.Configuration) *cobra.Command {
3232
icon string
3333
description string
3434
bricks []string
35-
noPyton bool
3635
noSketch bool
3736
fromApp string
3837
)
@@ -44,22 +43,21 @@ func newCreateCmd(cfg config.Configuration) *cobra.Command {
4443
RunE: func(cmd *cobra.Command, args []string) error {
4544
cobra.MinimumNArgs(1)
4645
name := args[0]
47-
return createHandler(cmd.Context(), cfg, name, icon, description, noPyton, noSketch, fromApp)
46+
return createHandler(cmd.Context(), cfg, name, icon, description, noSketch, fromApp)
4847
},
4948
}
5049

5150
cmd.Flags().StringVarP(&icon, "icon", "i", "", "Icon for the app")
5251
cmd.Flags().StringVarP(&description, "description", "d", "", "Description for the app")
5352
cmd.Flags().StringVarP(&fromApp, "from-app", "", "", "Create the new app from the path of an existing app")
5453
cmd.Flags().StringArrayVarP(&bricks, "bricks", "b", []string{}, "List of bricks to include in the app")
55-
cmd.Flags().BoolVarP(&noPyton, "no-python", "", false, "Do not include Python files")
5654
cmd.Flags().BoolVarP(&noSketch, "no-sketch", "", false, "Do not include Sketch files")
5755
cmd.MarkFlagsMutuallyExclusive("no-python", "no-sketch")
5856

5957
return cmd
6058
}
6159

62-
func createHandler(ctx context.Context, cfg config.Configuration, name string, icon string, description string, noPython, noSketch bool, fromApp string) error {
60+
func createHandler(ctx context.Context, cfg config.Configuration, name string, icon string, description string, noSketch bool, fromApp string) error {
6361
if fromApp != "" {
6462
id, err := servicelocator.GetAppIDProvider().ParseID(fromApp)
6563
if err != nil {
@@ -88,7 +86,6 @@ func createHandler(ctx context.Context, cfg config.Configuration, name string, i
8886
Name: name,
8987
Icon: icon,
9088
Description: description,
91-
SkipPython: noPython,
9289
SkipSketch: noSketch,
9390
}, servicelocator.GetAppIDProvider(), cfg)
9491
if err != nil {

internal/api/handlers/app_create.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,9 @@ func HandleAppCreate(
4444
defer r.Body.Close()
4545

4646
queryParams := r.URL.Query()
47-
skipPythonStr := queryParams.Get("skip-python")
4847
skipSketchStr := queryParams.Get("skip-sketch")
49-
50-
skipPython := queryParamsValidator(skipPythonStr)
5148
skipSketch := queryParamsValidator(skipSketchStr)
5249

53-
if skipPython && skipSketch {
54-
render.EncodeResponse(w, http.StatusBadRequest, models.ErrorResponse{Details: "cannot skip both python and sketch"})
55-
return
56-
}
57-
5850
var req CreateAppRequest
5951
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
6052
slog.Error("unable to decode app create request", slog.String("error", err.Error()))
@@ -68,7 +60,6 @@ func HandleAppCreate(
6860
Name: req.Name,
6961
Icon: req.Icon,
7062
Description: req.Description,
71-
SkipPython: skipPython,
7263
SkipSketch: skipSketch,
7364
},
7465
idProvider,

internal/orchestrator/app/generator/app_generator.go

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,22 @@ import (
3333

3434
const templateRoot = "app_template"
3535

36-
type Opts int
37-
38-
const (
39-
None Opts = 0
40-
SkipSketch Opts = 1 << iota
41-
SkipPython
42-
)
43-
4436
//go:embed all:app_template
4537
var fsApp embed.FS
4638

47-
func GenerateApp(basePath *paths.Path, app app.AppDescriptor, options Opts) error {
39+
func GenerateApp(basePath *paths.Path, app app.AppDescriptor, skipSketch bool) error {
4840
if err := basePath.MkdirAll(); err != nil {
4941
return fmt.Errorf("failed to create app directory: %w", err)
5042
}
51-
isSkipSketchSet := options&SkipSketch != 0
52-
isSkipPythonSet := options&SkipPython != 0
53-
54-
if !isSkipSketchSet {
43+
if !skipSketch {
5544
if err := generateSketch(basePath); err != nil {
5645
return fmt.Errorf("failed to create sketch: %w", err)
5746
}
5847
}
59-
if !isSkipPythonSet {
60-
if err := generatePython(basePath); err != nil {
61-
return fmt.Errorf("failed to create python: %w", err)
62-
}
63-
}
6448

49+
if err := generatePython(basePath); err != nil {
50+
return fmt.Errorf("failed to create python: %w", err)
51+
}
6552
if err := generateApp(basePath, app); err != nil {
6653
return fmt.Errorf("failed to create app.yaml: %w", err)
6754
}

internal/orchestrator/app/generator/app_generator_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,25 @@ func TestGenerateApp(t *testing.T) {
4040

4141
testCases := []struct {
4242
name string
43-
options Opts
43+
skipSketch bool
4444
goldenPath string
4545
}{
4646
{
4747
name: "generate complete app",
48-
options: None,
4948
goldenPath: "testdata/app-all.golden",
5049
},
5150
{
5251
name: "skip sketch",
53-
options: SkipSketch,
52+
skipSketch: true,
5453
goldenPath: "testdata/app-no-sketch.golden",
5554
},
56-
{
57-
name: "skip python",
58-
options: SkipPython,
59-
goldenPath: "testdata/app-no-python.golden",
60-
},
6155
}
6256

6357
for _, tc := range testCases {
6458
t.Run(tc.name, func(t *testing.T) {
6559
tempDir := t.TempDir()
6660

67-
err := GenerateApp(paths.New(tempDir), baseApp, tc.options)
61+
err := GenerateApp(paths.New(tempDir), baseApp, tc.skipSketch)
6862
require.NoError(t, err)
6963

7064
if os.Getenv("UPDATE_GOLDEN") == "true" {

internal/orchestrator/app/generator/testdata/app-no-python.golden/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

internal/orchestrator/app/generator/testdata/app-no-python.golden/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

internal/orchestrator/app/generator/testdata/app-no-python.golden/app.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

internal/orchestrator/app/generator/testdata/app-no-python.golden/sketch/sketch.ino

Lines changed: 0 additions & 9 deletions
This file was deleted.

internal/orchestrator/app/generator/testdata/app-no-python.golden/sketch/sketch.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

internal/orchestrator/orchestrator.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,6 @@ type CreateAppRequest struct {
749749
Name string
750750
Icon string
751751
Description string
752-
SkipPython bool
753752
SkipSketch bool
754753
}
755754

@@ -763,9 +762,6 @@ func CreateApp(
763762
idProvider *app.IDProvider,
764763
cfg config.Configuration,
765764
) (CreateAppResponse, error) {
766-
if req.SkipPython && req.SkipSketch {
767-
return CreateAppResponse{}, fmt.Errorf("cannot skip both python and sketch")
768-
}
769765
if req.Name == "" {
770766
return CreateAppResponse{}, fmt.Errorf("app name cannot be empty")
771767
}
@@ -784,16 +780,8 @@ func CreateApp(
784780
if err := newApp.IsValid(); err != nil {
785781
return CreateAppResponse{}, fmt.Errorf("%w: %v", app.ErrInvalidApp, err)
786782
}
787-
var options appgenerator.Opts = 0
788-
789-
if req.SkipSketch {
790-
options |= appgenerator.SkipSketch
791-
}
792-
if req.SkipPython {
793-
options |= appgenerator.SkipPython
794-
}
795783

796-
if err := appgenerator.GenerateApp(basePath, newApp, options); err != nil {
784+
if err := appgenerator.GenerateApp(basePath, newApp, req.SkipSketch); err != nil {
797785
return CreateAppResponse{}, fmt.Errorf("failed to create app: %w", err)
798786
}
799787
id, err := idProvider.IDFromPath(basePath)

0 commit comments

Comments
 (0)