status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/schema/sdk.go
}, dagql.Selector{ Field: "withWorkdir", Args: []dagql.NamedInput{ { Name: "path", Value: dagql.NewString(runtimeWorkdirPath), }, }, }, ); err != nil { return nil, fmt.Errorf("failed to exec go build in go module sdk container runtime: %w", err) } return ctr.Self, nil } func (sdk *goSDK) baseWithCodegen( ctx context.Context, mod *core.Module, configDir dagql.Instance[*core.Directory], sourceDirSubpath string, ) (dagql.Instance[*core.Container], error) { var ctr dagql.Instance[*core.Container] introspectionJSON, err := mod.DependencySchemaIntrospectionJSON(ctx) if err != nil { return ctr, fmt.Errorf("failed to get schema introspection json during %s module sdk codegen: %w", mod.Name(), err) } ctr, err = sdk.base(ctx) if err != nil { return ctr, err }
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/schema/sdk.go
var updatedConfigDir dagql.Instance[*core.Directory] if err := sdk.dag.Select(ctx, configDir, &updatedConfigDir, dagql.Selector{ Field: "withoutFile", Args: []dagql.NamedInput{ { Name: "path", Value: dagql.String(filepath.Join(sourceDirSubpath, "dagger.gen.go")), }, }, }); err != nil { return ctr, fmt.Errorf("failed to remove dagger.gen.go from source directory: %w", err) } if err := sdk.dag.Select(ctx, ctr, &ctr, dagql.Selector{ Field: "withNewFile", Args: []dagql.NamedInput{ { Name: "path", Value: dagql.NewString(goSDKIntrospectionJSONPath), }, { Name: "contents", Value: dagql.NewString(introspectionJSON), }, { Name: "permissions", Value: dagql.NewInt(0444),
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/schema/sdk.go
}, }, }, dagql.Selector{ Field: "withMountedDirectory", Args: []dagql.NamedInput{ { Name: "path", Value: dagql.NewString(goSDKUserModSourceDirPath), }, { Name: "source", Value: dagql.NewID[*core.Directory](updatedConfigDir.ID()), }, }, }, dagql.Selector{ Field: "withWorkdir", Args: []dagql.NamedInput{ { Name: "path", Value: dagql.NewString(filepath.Join(goSDKUserModSourceDirPath, sourceDirSubpath)), }, }, }, dagql.Selector{ Field: "withoutDefaultArgs", }, dagql.Selector{ Field: "withExec", Args: []dagql.NamedInput{ { Name: "args", Value: dagql.ArrayInput[dagql.String]{
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/schema/sdk.go
"--module-source-root", goSDKUserModSourceDirPath, "--module-name", dagql.String(mod.OriginalName), "--propagate-logs=true", "--introspection-json-path", goSDKIntrospectionJSONPath, }, }, { Name: "experimentalPrivilegedNesting", Value: dagql.NewBoolean(true), }, }, }); err != nil { return ctr, fmt.Errorf("failed to mount introspection json file into go module sdk container codegen: %w", err) } return ctr, nil } func (sdk *goSDK) base(ctx context.Context) (dagql.Instance[*core.Container], error) { var inst dagql.Instance[*core.Container] ctx, recorder := progrock.WithGroup(ctx, "load builtin module sdk go") tarDir, tarName := filepath.Split(distconsts.GoSDKEngineContainerTarballPath) _, desc, err := sdk.root.Buildkit.EngineContainerLocalImport( ctx, recorder, sdk.root.Platform.Spec(), tarDir, nil, []string{tarName}, ) if err != nil { return inst, fmt.Errorf("failed to import go module sdk tarball from engine container filesystem: %s", err)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/schema/sdk.go
} blobDir, err := core.LoadBlob(ctx, sdk.dag, desc) if err != nil { return inst, fmt.Errorf("failed to load go module sdk tarball: %w", err) } var tarballFile dagql.Instance[*core.File] if err := sdk.dag.Select(ctx, blobDir, &tarballFile, dagql.Selector{ Field: "file", Args: []dagql.NamedInput{ { Name: "path", Value: dagql.String(tarName), }, }, }); err != nil { return inst, fmt.Errorf("failed to get tarball file from go module sdk tarball: %w", err) } var modCache dagql.Instance[*core.CacheVolume] if err := sdk.dag.Select(ctx, sdk.dag.Root(), &modCache, dagql.Selector{ Field: "cacheVolume", Args: []dagql.NamedInput{ { Name: "key", Value: dagql.String("modgomodcache"), }, }, }); err != nil { return inst, fmt.Errorf("failed to get mod cache from go module sdk tarball: %w", err) } var buildCache dagql.Instance[*core.CacheVolume]
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/schema/sdk.go
if err := sdk.dag.Select(ctx, sdk.dag.Root(), &buildCache, dagql.Selector{ Field: "cacheVolume", Args: []dagql.NamedInput{ { Name: "key", Value: dagql.String("modgobuildcache"), }, }, }); err != nil { return inst, fmt.Errorf("failed to get build cache from go module sdk tarball: %w", err) } var ctr dagql.Instance[*core.Container] if err := sdk.dag.Select(ctx, sdk.dag.Root(), &ctr, dagql.Selector{ Field: "container", }, dagql.Selector{ Field: "import", Args: []dagql.NamedInput{ { Name: "source", Value: dagql.NewID[*core.File](tarballFile.ID()), }, }, }, dagql.Selector{ Field: "withMountedCache", Args: []dagql.NamedInput{ { Name: "path", Value: dagql.String("/go/pkg/mod"), }, {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
core/schema/sdk.go
Name: "cache", Value: dagql.NewID[*core.CacheVolume](modCache.ID()), }, { Name: "sharing", Value: core.CacheSharingModeShared, }, }, }, dagql.Selector{ Field: "withMountedCache", Args: []dagql.NamedInput{ { Name: "path", Value: dagql.String("/root/.cache/go-build"), }, { Name: "cache", Value: dagql.NewID[*core.CacheVolume](buildCache.ID()), }, { Name: "sharing", Value: core.CacheSharingModeShared, }, }, }); err != nil { return inst, fmt.Errorf("failed to get container from go module sdk tarball: %w", err) } return ctr, nil }
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
package dagql import ( "context" "encoding/json" "fmt" "reflect" "strconv" "strings" "github.com/dagger/dagger/dagql/idproto" "github.com/vektah/gqlparser/v2/ast" "golang.org/x/exp/constraints" ) type Typed interface { Type() *ast.Type } type Type interface { TypeName() string } type ObjectType interface { Type Typed() Typed IDType() (IDType, bool)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
New(*idproto.ID, Typed) (Object, error) ParseField(context.Context, *ast.Field, map[string]any) (Selector, *ast.Type, error) Extend(FieldSpec, FieldFunc) } type IDType interface { Input IDable ScalarType } type FieldFunc func(context.Context, Object, map[string]Input) (Typed, error) type IDable interface { ID() *idproto.ID } type Object interface { Typed IDable ObjectType() ObjectType IDFor(context.Context, Selector) (*idproto.ID, error)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
Select(context.Context, Selector) (Typed, error) } type ScalarType interface { Type InputDecoder } type Input interface { Typed idproto.Literate Decoder() InputDecoder } type Setter interface { SetField(reflect.Value) error } type InputDecoder interface { DecodeInput(any) (Input, error) } type Int int64 func NewInt[T constraints.Integer](val T) Int {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
return Int(val) } var _ ScalarType = Int(0) func (Int) TypeName() string { return "Int" } func (i Int) TypeDefinition() *ast.Definition { return &ast.Definition{ Kind: ast.Scalar, Name: i.TypeName(), Description: "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.", BuiltIn: true, } } func (Int) DecodeInput(val any) (Input, error) { switch x := val.(type) { case int: return NewInt(x), nil case int32: return NewInt(x), nil case int64: return NewInt(x), nil case json.Number: i, err := x.Int64()
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
if err != nil { return nil, err } return NewInt(i), nil case string: i, err := strconv.ParseInt(x, 0, 64) if err != nil { return nil, err } return NewInt(i), nil default: return nil, fmt.Errorf("cannot create Int from %T", x) } } var _ Input = Int(0) func (Int) Decoder() InputDecoder { return Int(0) } func (i Int) Int() int { return int(i) } func (i Int) Int64() int64 { return int64(i) } func (i Int) ToLiteral() *idproto.Literal { return &idproto.Literal{ Value: &idproto.Literal_Int{ Int: i.Int64(), }, }
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
} func (Int) Type() *ast.Type { return &ast.Type{ NamedType: "Int", NonNull: true, } } func (i Int) MarshalJSON() ([]byte, error) { return json.Marshal(i.Int()) } func (i *Int) UnmarshalJSON(p []byte) error { var num int if err := json.Unmarshal(p, &num); err != nil { return err } *i = Int(num) return nil } var _ Setter = ID[Typed]{} func (i Int) SetField(v reflect.Value) error { switch v.Interface().(type) { case int, int64: v.SetInt(i.Int64()) return nil default: return fmt.Errorf("cannot set field of type %T with %T", v.Interface(), i) } } type Float float64 func NewFloat(val float64) Float {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
return Float(val) } var _ ScalarType = Float(0) func (Float) TypeName() string { return "Float" } func (f Float) TypeDefinition() *ast.Definition { return &ast.Definition{ Kind: ast.Scalar, Name: f.TypeName(), Description: "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http:en.wikipedia.org/wiki/IEEE_floating_point).", BuiltIn: true, } } func (Float) DecodeInput(val any) (Input, error) { switch x := val.(type) { case float32: return NewFloat(float64(x)), nil case float64: return NewFloat(x), nil
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
case json.Number: i, err := x.Float64() if err != nil { return nil, err } return NewFloat(i), nil case string: i, err := strconv.ParseFloat(x, 64) if err != nil { return nil, err } return NewFloat(i), nil default: return nil, fmt.Errorf("cannot create Float from %T", x) } } var _ Input = Float(0) func (Float) Decoder() InputDecoder { return Float(0) } func (f Float) ToLiteral() *idproto.Literal { return &idproto.Literal{ Value: &idproto.Literal_Float{ Float: f.Float64(), }, } } func (f Float) Float64() float64 { return float64(f) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
func (Float) Type() *ast.Type { return &ast.Type{ NamedType: "Float", NonNull: true, } } func (f Float) MarshalJSON() ([]byte, error) { return json.Marshal(f.Float64()) } func (f *Float) UnmarshalJSON(p []byte) error { var num float64 if err := json.Unmarshal(p, &num); err != nil { return err } *f = Float(num) return nil } var _ Setter = Float(0) func (f Float) SetField(v reflect.Value) error { switch x := v.Interface().(type) { case float64: v.SetFloat(f.Float64()) _ = x return nil default: return fmt.Errorf("cannot set field of type %T with %T", v.Interface(), f) } } type Boolean bool func NewBoolean(val bool) Boolean {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
return Boolean(val) } var _ Typed = Boolean(false) func (Boolean) Type() *ast.Type { return &ast.Type{ NamedType: "Boolean", NonNull: true, } } var _ ScalarType = Boolean(false) func (Boolean) TypeName() string { return "Boolean" } func (b Boolean) TypeDefinition() *ast.Definition { return &ast.Definition{ Kind: ast.Scalar, Name: b.TypeName(),
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
Description: "The `Boolean` scalar type represents `true` or `false`.", BuiltIn: true, } } func (Boolean) DecodeInput(val any) (Input, error) { switch x := val.(type) { case bool: return NewBoolean(x), nil case string: b, err := strconv.ParseBool(x) if err != nil { return nil, err } return NewBoolean(b), nil default: return nil, fmt.Errorf("cannot create Boolean from %T", x) } } var _ Input = Boolean(false) func (Boolean) Decoder() InputDecoder { return Boolean(false) } func (b Boolean) ToLiteral() *idproto.Literal { return &idproto.Literal{ Value: &idproto.Literal_Bool{ Bool: b.Bool(), }, } } func (b Boolean) Bool() bool {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
return bool(b) } func (b Boolean) MarshalJSON() ([]byte, error) { return json.Marshal(b.Bool()) } func (b *Boolean) UnmarshalJSON(p []byte) error { var val bool if err := json.Unmarshal(p, &val); err != nil { return err } *b = Boolean(val) return nil } var _ Setter = Boolean(false) func (b Boolean) SetField(v reflect.Value) error { switch v.Interface().(type) { case bool: v.SetBool(b.Bool()) return nil default: return fmt.Errorf("cannot set field of type %T with %T", v.Interface(), b) } } type String string func NewString(val string) String { return String(val) } var _ Typed = String("") func (String) Type() *ast.Type { return &ast.Type{
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
NamedType: "String", NonNull: true, } } var _ ScalarType = String("") func (String) TypeName() string { return "String" } func (s String) TypeDefinition() *ast.Definition { return &ast.Definition{ Kind: ast.Scalar, Name: s.TypeName(), Description: "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.", BuiltIn: true, } } func (String) DecodeInput(val any) (Input, error) { switch x := val.(type) { case string: return NewString(x), nil default: return nil, fmt.Errorf("cannot create String from %T", x) } } var _ Input = String("") func (String) Decoder() InputDecoder { return String("") } func (s String) ToLiteral() *idproto.Literal { return &idproto.Literal{
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
Value: &idproto.Literal_String_{ String_: s.String(), }, } } func (s String) MarshalJSON() ([]byte, error) { return json.Marshal(s.String()) } func (s *String) UnmarshalJSON(p []byte) error { var str string if err := json.Unmarshal(p, &str); err != nil { return err } *s = String(str) return nil } func (s String) String() string { return string(s) } var _ Setter = String("") func (s String) SetField(v reflect.Value) error { switch v.Interface().(type) { case string: v.SetString(s.String()) return nil default: return fmt.Errorf("cannot set field of type %T with %T", v.Interface(), s) } } type ID[T Typed] struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
id *idproto.ID inner T } func NewID[T Typed](id *idproto.ID) ID[T] { return ID[T]{ id: id, } } func NewDynamicID[T Typed](id *idproto.ID, typed T) ID[T] { return ID[T]{ id: id, inner: typed, } } func (i ID[T]) TypeName() string { return i.inner.Type().Name() + "ID" } var _ Typed = ID[Typed]{} func (i ID[T]) Type() *ast.Type { return &ast.Type{ NamedType: i.TypeName(), NonNull: true,
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
} } var _ IDable = ID[Typed]{} func (i ID[T]) ID() *idproto.ID { return i.id } var _ ScalarType = ID[Typed]{} func (i ID[T]) TypeDefinition() *ast.Definition { return &ast.Definition{ Kind: ast.Scalar, Name: i.TypeName(), Description: fmt.Sprintf( "The `%s` scalar type represents an identifier for an object of type %s.", i.TypeName(), i.inner.Type().Name(), ), BuiltIn: true, } } func (i ID[T]) DecodeInput(val any) (Input, error) { switch x := val.(type) { case *idproto.ID: return ID[T]{id: x, inner: i.inner}, nil case string: if err := (&i).Decode(x); err != nil { return nil, err } return i, nil default: return nil, fmt.Errorf("cannot create ID[%T] from %T: %#v", i.inner, x, x)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
} } func (i ID[T]) String() string { dig, err := i.id.Digest() if err != nil { panic(err) } return fmt.Sprintf("%s@%s", i.inner.Type().Name(), dig) } var _ Setter = ID[Typed]{} func (i ID[T]) SetField(v reflect.Value) error { switch v.Interface().(type) { case *idproto.ID: v.Set(reflect.ValueOf(i.ID)) return nil default: return fmt.Errorf("cannot set field of type %T with %T", v.Interface(), i) } } var _ Input = ID[Typed]{} func (i ID[T]) Decoder() InputDecoder { return ID[T]{inner: i.inner} } func (i ID[T]) ToLiteral() *idproto.Literal { return &idproto.Literal{ Value: &idproto.Literal_Id{ Id: i.id, }, } }
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
func (i ID[T]) Encode() (string, error) { return i.id.Encode() } func (i ID[T]) Display() string { return i.id.Display() } func (i *ID[T]) Decode(str string) error { if str == "" { return fmt.Errorf("cannot decode empty string as ID") } expectedName := i.inner.Type().Name() var idp idproto.ID if err := idp.Decode(str); err != nil { return err } if idp.Type == nil { return fmt.Errorf("expected %q ID, got untyped ID", expectedName) } if idp.Type.NamedType != expectedName { return fmt.Errorf("expected %q ID, got %s ID", expectedName, idp.Type.ToAST()) } i.id = &idp return nil } var _ json.Marshaler = ID[Typed]{} func (i ID[T]) MarshalJSON() ([]byte, error) { enc, err := i.Encode() if err != nil { return nil, err }
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
return json.Marshal(enc) } var _ json.Unmarshaler = (*ID[Typed])(nil) func (i *ID[T]) UnmarshalJSON(p []byte) error { var str string if err := json.Unmarshal(p, &str); err != nil { return err } return i.Decode(str) } func (i ID[T]) Load(ctx context.Context, server *Server) (Instance[T], error) { val, err := server.Load(ctx, i.id) if err != nil { return Instance[T]{}, fmt.Errorf("load %s: %w", i.id.Display(), err) } obj, ok := val.(Instance[T]) if !ok { return Instance[T]{}, fmt.Errorf("load %s: expected %T, got %T", i.id.Display(), obj, val) } return obj, nil } type Enumerable interface { Len() int Nth(int) (Typed, error) } type ArrayInput[I Input] []I func MapArrayInput[T Input, R Typed](opt ArrayInput[T], fn func(T) (R, error)) (Array[R], error) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
r := make(Array[R], len(opt)) for i, val := range opt { var err error r[i], err = fn(val) if err != nil { return nil, fmt.Errorf("map array[%d]: %w", i, err) } } return r, nil } func (a ArrayInput[S]) ToArray() Array[S] { return Array[S](a) } var _ Typed = ArrayInput[Input]{} func (a ArrayInput[S]) Type() *ast.Type { var elem S return &ast.Type{ Elem: elem.Type(),
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
NonNull: true, } } var _ Input = ArrayInput[Input]{} func (a ArrayInput[S]) Decoder() InputDecoder { return a } var _ InputDecoder = ArrayInput[Input]{} func (a ArrayInput[I]) DecodeInput(val any) (Input, error) { var zero I decoder := zero.Decoder() switch x := val.(type) { case []any: arr := make(ArrayInput[I], len(x)) for i, val := range x { elem, err := decoder.DecodeInput(val) if err != nil { return nil, fmt.Errorf("ArrayInput.New[%d]: %w", i, err) } arr[i] = elem.(I) } return arr, nil case string: var vals []any dec := json.NewDecoder(strings.NewReader(x)) dec.UseNumber() if err := dec.Decode(&vals); err != nil { return nil, fmt.Errorf("decode %q: %w", x, err) } return a.DecodeInput(vals)
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
default: return nil, fmt.Errorf("cannot create ArrayInput from %T", x) } } func (i ArrayInput[S]) ToLiteral() *idproto.Literal { list := &idproto.List{} for _, elem := range i { list.Values = append(list.Values, elem.ToLiteral()) } return &idproto.Literal{ Value: &idproto.Literal_List{ List: list, }, } } var _ Setter = ArrayInput[Input]{} func (d ArrayInput[I]) SetField(val reflect.Value) error { if val.Kind() != reflect.Slice { return fmt.Errorf("expected slice, got %v", val.Kind()) } val.Set(reflect.MakeSlice(val.Type(), len(d), len(d))) for i, elem := range d { if err := assign(val.Index(i), elem); err != nil { return err } } return nil } type Array[T Typed] []T func ToArray[A any, T Typed](fn func(A) T, elems ...A) Array[T] {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
arr := make(Array[T], len(elems)) for i, elem := range elems { arr[i] = fn(elem) } return arr } func NewStringArray(elems ...string) Array[String] { return ToArray(NewString, elems...) } func NewBoolArray(elems ...bool) Array[Boolean] { return ToArray(NewBoolean, elems...) } func NewIntArray(elems ...int) Array[Int] {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
return ToArray(NewInt, elems...) } func NewFloatArray(elems ...float64) Array[Float] { return ToArray(NewFloat, elems...) } var _ Typed = Array[Typed]{} func (i Array[T]) Type() *ast.Type { var t T return &ast.Type{ Elem: t.Type(), NonNull: true, } } var _ Enumerable = Array[Typed]{} func (arr Array[T]) Len() int { return len(arr) } func (arr Array[T]) Nth(i int) (Typed, error) { if i < 1 || i > len(arr) { return nil, fmt.Errorf("index %d out of bounds", i) } return arr[i-1], nil } type EnumValue interface { Input ~string } type EnumValues[T EnumValue] struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
values []T descriptions []string } func NewEnum[T EnumValue](vals ...T) *EnumValues[T] { return &EnumValues[T]{ values: vals, descriptions: make([]string, len(vals)), } } func (e *EnumValues[T]) Type() *ast.Type { var zero T return zero.Type() } func (e *EnumValues[T]) TypeName() string { return e.Type().Name() } func (e *EnumValues[T]) TypeDefinition() *ast.Definition { def := &ast.Definition{ Kind: ast.Enum, Name: e.TypeName(), EnumValues: e.PossibleValues(), } var val T if isType, ok := any(val).(Descriptive); ok { def.Description = isType.TypeDescription() } return def
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
} func (e *EnumValues[T]) DecodeInput(val any) (Input, error) { switch x := val.(type) { case string: return e.Lookup(x) default: return nil, fmt.Errorf("cannot create Enum from %T", x) } } func (e *EnumValues[T]) PossibleValues() ast.EnumValueList { var values ast.EnumValueList for i, val := range e.values { values = append(values, &ast.EnumValueDefinition{ Name: string(val), Description: e.descriptions[i], }) } return values } func (e *EnumValues[T]) Literal(val T) *idproto.Literal { return &idproto.Literal{ Value: &idproto.Literal_Enum{ Enum: string(val), }, } } func (e *EnumValues[T]) Lookup(val string) (T, error) { var enum T for _, possible := range e.values { if val == string(possible) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
return possible, nil } } return enum, fmt.Errorf("invalid enum value %q", val) } func (e *EnumValues[T]) Register(val T, desc ...string) T { e.values = append(e.values, val) e.descriptions = append(e.descriptions, FormatDescription(desc...)) return val } func (e *EnumValues[T]) Install(srv *Server) { var zero T srv.scalars[zero.Type().Name()] = e } type InputType[T Type] struct{} func MustInputSpec(val Type) InputObjectSpec { spec := InputObjectSpec{ Name: val.TypeName(), } if desc, ok := val.(Descriptive); ok { spec.Description = desc.TypeDescription() } inputs, err := inputSpecsForType(val, true) if err != nil { panic(fmt.Errorf("input specs for %T: %w", val, err)) } spec.Fields = inputs return spec } type InputObjectSpec struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,312
Modules: `dag.Host()` name is extremely confusing
When module code uses `dag.Host()`, the "host" it refers to is the module container's "host", not the CLI caller's host. While this is technically consistent, it's very non-obvious at first glance and a constant source of confusion. I think at a minimum we need to change `Host` to something with a more obvious name. TBD if this change also impacts non-module SDKs or if it's somehow scoped just to the codegen for modules. There's certainly larger scope changes to the API that could also be worth discussing, but changing to a more clear name seems like the bare-minimum baseline thing to do here. --- As a side-note, support for Module code being able to read files/env vars/etc. from the *CLI caller's host* is a separate topic, discussed in this other issue https://github.com/dagger/dagger/issues/6112
https://github.com/dagger/dagger/issues/6312
https://github.com/dagger/dagger/pull/6535
c241d901a48f699a1d62f0daad882c88730e1fba
7a63c3d019530d1f08b2f72cc28e753d99b5896d
2023-12-21T19:46:28Z
go
2024-02-01T14:23:42Z
dagql/types.go
Name string Description string Fields InputSpecs } func (spec InputObjectSpec) Install(srv *Server) { srv.InstallTypeDef(spec) } func (spec InputObjectSpec) Type() *ast.Type { return &ast.Type{ NamedType: spec.Name, NonNull: true, } } func (spec InputObjectSpec) TypeName() string { return spec.Name } func (spec InputObjectSpec) TypeDefinition() *ast.Definition { return &ast.Definition{ Kind: ast.InputObject, Name: spec.Name, Description: spec.Description, Fields: spec.Fields.FieldDefinitions(), } }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/cloud.go
package main import ( "context" "os" "github.com/dagger/dagger/internal/cloud" "github.com/dagger/dagger/internal/cloud/auth" "github.com/spf13/cobra" ) func init() { cloud := &CloudCLI{} rootCmd.PersistentFlags().StringVar(&cloud.API, "api", "https://api.dagger.cloud", "Dagger Cloud API URL") rootCmd.PersistentFlags().MarkHidden("api") loginCmd := &cobra.Command{ Use: "login", Short: "Log in to Dagger Cloud", RunE: cloud.Login, } rootCmd.AddCommand(loginCmd) logoutCmd := &cobra.Command{ Use: "logout", Short: "Log out from Dagger Cloud", RunE: cloud.Logout, } rootCmd.AddCommand(logoutCmd) } type CloudCLI struct { API string
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/cloud.go
} func (cli *CloudCLI) Client(ctx context.Context) (*cloud.Client, error) { return cloud.NewClient(ctx, cli.API) } func (cli *CloudCLI) Login(cmd *cobra.Command, args []string) error { lg := Logger(os.Stderr) ctx := lg.WithContext(cmd.Context()) if err := auth.Login(ctx); err != nil { return err } client, err := cli.Client(ctx) if err != nil { return err } user, err := client.User(ctx) if err != nil { return err } lg.Info().Str("user", user.ID).Msg("logged in") return nil } func (cli *CloudCLI) Logout(cmd *cobra.Command, args []string) error { lg := Logger(os.Stderr) if err := auth.Logout(); err != nil { return err } lg.Info().Msg("logged out") return nil }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
package main import ( "context" "errors" "fmt" "io" "os" "sort" "strings" "dagger.iodagger" "dagger.iodaggerquerybuilder" "github.comdaggerdaggerengineclient" "github.comjujuansitermtabwriter" "github.commueslitermenv" "github.comspf13cobra" "github.comspf13pflag" "github.comvitoprogrock" ) const (
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
Directory string = "Directory" Container string = "Container" File string = "File" Secret string = "Secret" Service string = "Service" Terminal string = "Terminal" PortForward string = "PortForward" CacheVolume string = "CacheVolume" ) var funcCmds = FuncCommands{ funcListCmd, callCmd, } var funcListCmd = &FuncCommand{ Name: "functions [flags] [FUNCTION]...", Short: `List available functions`, Long: strings.ReplaceAll(`List available functions in a module. This is similar to ´dagger call --help´, but only focused on showing the available functions. `, "´", "`", ), Execute: func(fc *FuncCommand, cmd *cobra.Command) error { tw := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 0, 3, ' ', tabwriter.DiscardEmptyColumns) var o functionProvider = fc.mod.GetMainObject() fmt.Fprintf(tw, "%s\t%s\n", termenv.String("Name").Bold(), termenv.String("Description").Bold(), )
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
for _, field := range cmd.Flags().Args() { nextFunc, err := o.GetFunction(field) if err != nil { return err } nextType := nextFunc.ReturnType if nextType.AsFunctionProvider() != nil { o = fc.mod.GetFunctionProvider(nextType.Name()) continue } return fmt.Errorf("function '%s' returns non-object type %v", field, nextType.Kind) } fns := o.GetFunctions() sort.Slice(fns, func(i, j int) bool { return fns[i].Name < fns[j].Name })
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
for _, fn := range fns { desc := strings.SplitN(fn.Description, "\n", 2)[0] if desc == "" { desc = "-" } fmt.Fprintf(tw, "%s\t%s\n", cliName(fn.Name), desc, ) } return tw.Flush() }, } type FuncCommands []*FuncCommand func (fcs FuncCommands) AddFlagSet(flags *pflag.FlagSet) { for _, cmd := range fcs.All() { cmd.PersistentFlags().AddFlagSet(flags) } } func (fcs FuncCommands) AddParent(rootCmd *cobra.Command) { rootCmd.AddCommand(fcs.All()...) } func (fcs FuncCommands) All() []*cobra.Command { cmds := make([]*cobra.Command, len(fcs)) for i, fc := range fcs { cmds[i] = fc.Command() } return cmds } func setCmdOutput(cmd *cobra.Command, vtx *progrock.VertexRecorder) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
if silent { return } var stdout io.Writer var stderr io.Writer if stdoutIsTTY { stdout = vtx.Stdout() } else { stdout = os.Stdout } if stderrIsTTY { stderr = vtx.Stderr() } else { stderr = os.Stderr } cmd.SetOut(stdout) cmd.SetErr(stderr) } FuncCommand is a config object used to create a dynamic set of commands for querying a module's functions. type FuncCommand struct { The name of the command (or verb), as shown in usage. Name string Aliases is an array of aliases that can be used instead of the first word in Use.
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
Aliases []string Short is the short description shown in the 'help' output. Short string Long is the long message shown in the 'help <this-command>' output. Long string Example is examples of how to use the command. Example string Init is called when the command is created and initialized, before execution. It can be useful to add persistent flags for all subcommands here. Init func(*cobra.Command) Execute circumvents the default behavior of traversing subcommands from the arguments, but still has access to the loaded objects from the module. Execute func(*FuncCommand, *cobra.Command) error BeforeParse is called before parsing the flags for a subcommand. It can be useful to add any additional flags for a subcommand here. BeforeParse func(*FuncCommand, *cobra.Command, *modFunction) error OnSelectObjectLeaf is called when a user provided command ends in a object and no more sub-commands are provided. If set, it should make another selection on the object that results return no error. Otherwise if it doesn't handle the object, it should return an error. OnSelectObjectLeaf func(*FuncCommand, string) error BeforeRequest is called before making the request with the query that contains the whole chain of functions.
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
It can be useful to validate the return type of the function or as a last effort to select a GraphQL sub-field. BeforeRequest func(*FuncCommand, *cobra.Command, *modTypeDef) error AfterResponse is called when the query has completed and returned a result. AfterResponse func(*FuncCommand, *cobra.Command, *modTypeDef, any) error cmd is the parent cobra command. cmd *cobra.Command mod is the loaded module definition. mod *moduleDef showHelp is set in the loader vertex to flag whether to show the help in the execution vertex. showHelp bool showUsage flags whether to show a one-line usage message after error. showUsage bool q *querybuilder.Selection c *client.Client } func (fc *FuncCommand) Command() *cobra.Command { if fc.cmd == nil { fc.cmd = &cobra.Command{ Use: fc.Name, Aliases: fc.Aliases, Short: fc.Short, Long: fc.Long, Example: fc.Example, GroupID: moduleGroup.ID, Annotations: map[string]string{ "experimental": "", },
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
DisableFlagParsing: true, DisableFlagsInUseLine: true, PreRunE: func(c *cobra.Command, a []string) error { c.DisableFlagParsing = false c.Flags().SetInterspersed(false) c.SetGlobalNormalizationFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName { return pflag.NormalizedName(cliName(name)) }) c.FParseErrWhitelist.UnknownFlags = true if err := c.ParseFlags(a); err != nil { return c.FlagErrorFunc()(c, err) } c.FParseErrWhitelist.UnknownFlags = false
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
fc.showHelp, _ = c.Flags().GetBool("help") return nil }, RunE: func(c *cobra.Command, a []string) error { return withEngineAndTUI(c.Context(), client.Params{}, func(ctx context.Context, engineClient *client.Client) (rerr error) { fc.c = engineClient c.SetContext(ctx) c.SilenceErrors = true return fc.execute(c, a) }) }, } if fc.Init != nil { fc.Init(fc.cmd) } } return fc.cmd } func (fc *FuncCommand) execute(c *cobra.Command, a []string) (rerr error) { ctx := c.Context() rec := progrock.FromContext(ctx) NB: Don't print full os.Args in Vertex name because we don't know which flags hold a secret value yet and don't want to risk exposing them. We'll print just the command path when we have the leaf command. loader := rec.Vertex("cmd-func-loader", "load "+c.Name())
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
setCmdOutput(c, loader) cmd, flags, err := fc.load(c, a, loader) loader.Done(err) if err != nil { return err } vtx := rec.Vertex("cmd-func-exec", cmd.CommandPath(), progrock.Focused()) setCmdOutput(c, vtx) defer func() { if rerr != nil { cmd.PrintErrln("Error:", rerr.Error()) if fc.showUsage { cmd.PrintErrf("Run '%v --help' for usage.\n", cmd.CommandPath()) } } vtx.Done(rerr) }() TODO: Move help output out of progrock? if fc.showHelp { if cmd != c { cmd.Aliases = nil } return cmd.Help() } There should be no args left, if there are it's an unknown command. if err := cobra.NoArgs(cmd, flags); err != nil { return err }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
if fc.Execute != nil { return fc.Execute(fc, cmd) } No args to the parent command, default to showing help. if cmd == c { return cmd.Help() } err = cmd.RunE(cmd, flags) if err != nil { return err } return nil } func (fc *FuncCommand) load(c *cobra.Command, a []string, vtx *progrock.VertexRecorder) (cmd *cobra.Command, _ []string, rerr error) { ctx := c.Context() dag := fc.c.Dagger() Print error in current vertex, before completing it. defer func() { if cmd == nil { cmd = c } if rerr != nil { cmd.PrintErrln("Error:", rerr.Error()) if fc.showHelp { cmd.Help() }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
if fc.showUsage { cmd.PrintErrf("Run '%v --help' for usage.\n", cmd.CommandPath()) } } }() load := vtx.Task("loading module") modConf, err := getDefaultModuleConfiguration(ctx, dag, "") if err != nil { return nil, nil, fmt.Errorf("failed to get configured module: %w", err) } if !modConf.FullyInitialized() { return nil, nil, fmt.Errorf("module at source dir %q doesn't exist or is invalid", modConf.LocalSourcePath) } mod := modConf.Mod.Initialize() _, err = mod.Serve(ctx) load.Done(err) if err != nil { return nil, nil, err } load = vtx.Task("loading objects") modDef, err := loadModTypeDefs(ctx, dag, mod) load.Done(err) if err != nil { return nil, nil, err } obj := modDef.GetMainObject() if obj == nil { return nil, nil, fmt.Errorf("main object not found") } fc.mod = modDef
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
if fc.Execute != nil { return nil, nil, nil } if obj.Constructor != nil { if err := fc.addArgsForFunction(c, a, obj.Constructor, dag); err != nil { return nil, nil, err } fc.selectFunc(obj.Name, obj.Constructor, c, dag) } else { fc.Select(obj.Name) } Add main object's functions as subcommands fc.addSubCommands(c, dag, obj) if fc.showHelp { return nil, nil, nil } traverse := vtx.Task("traversing arguments") cmd, flags, err := fc.traverse(c) defer func() { traverse.Done(rerr) }() if err != nil { if errors.Is(err, pflag.ErrHelp) { fc.showHelp = true return cmd, flags, nil } fc.showUsage = true return cmd, flags, err } return cmd, flags, nil
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
} traverse the arguments to build the command tree and return the leaf command. func (fc *FuncCommand) traverse(c *cobra.Command) (*cobra.Command, []string, error) { cmd, args, err := c.Find(c.Flags().Args()) if err != nil { return cmd, args, err } Leaf command if cmd == c { return cmd, args, nil } cmd.SetContext(c.Context()) cmd.InitDefaultHelpFlag() Load and ParseFlags err = cmd.PreRunE(cmd, args) if err != nil { return cmd, args, err } return fc.traverse(cmd) } func (fc *FuncCommand) addSubCommands(cmd *cobra.Command, dag *dagger.Client, fnProvider functionProvider) { if fnProvider != nil { for _, fn := range fnProvider.GetFunctions() { subCmd := fc.makeSubCmd(dag, fn) cmd.AddCommand(subCmd) } } } func (fc *FuncCommand) makeSubCmd(dag *dagger.Client, fn *modFunction) *cobra.Command { newCmd := &cobra.Command{
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
Use: cliName(fn.Name), Short: fn.Description, PreRunE: func(cmd *cobra.Command, args []string) (err error) { if err := fc.addArgsForFunction(cmd, args, fn, dag); err != nil { return err } fnProvider := fn.ReturnType.AsFunctionProvider() if fnProvider == nil && fn.ReturnType.AsList != nil { fnProvider = fn.ReturnType.AsList.ElementTypeDef.AsFunctionProvider() } fc.addSubCommands(cmd, dag, fnProvider) help, _ := cmd.Flags().GetBool("help") if help { return pflag.ErrHelp } return fc.selectFunc(fn.Name, fn, cmd, dag) }, RunE: func(cmd *cobra.Command, args []string) (err error) { switch fn.ReturnType.Kind { case dagger.ObjectKind, dagger.InterfaceKind: if fc.OnSelectObjectLeaf == nil { fc.showUsage = true return fmt.Errorf("%q requires a sub-command", cmd.Name()) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
err := fc.OnSelectObjectLeaf(fc, fn.ReturnType.Name()) if err != nil { fc.showUsage = true return fmt.Errorf("invalid selection for command %q: %w", cmd.Name(), err) } case dagger.ListKind: fnProvider := fn.ReturnType.AsList.ElementTypeDef.AsFunctionProvider() if fnProvider != nil && len(fnProvider.GetFunctions()) > 0 { fc.showUsage = true return fmt.Errorf("%q requires a sub-command", cmd.Name()) } } if fc.BeforeRequest != nil { if err = fc.BeforeRequest(fc, cmd, fn.ReturnType); err != nil { return err } } ctx := cmd.Context() query, _ := fc.q.Build(ctx) rec := progrock.FromContext(ctx) rec.Debug("executing", progrock.Labelf("query", "%+v", query)) var response any q := fc.q.Bind(&response) if err := q.Execute(ctx, dag.GraphQLClient()); err != nil { return fmt.Errorf("response from query: %w", err) } if fc.AfterResponse != nil { return fc.AfterResponse(fc, cmd, fn.ReturnType, response) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
if fn.ReturnType.Kind != dagger.VoidKind { cmd.Println(response) } return nil }, } Allow using the function name from the SDK as an alias for the command. if fn.Name != newCmd.Name() { newCmd.Aliases = append(newCmd.Aliases, fn.Name) } newCmd.Flags().SetInterspersed(false) return newCmd } func (fc *FuncCommand) addArgsForFunction(cmd *cobra.Command, cmdArgs []string, fn *modFunction, dag *dagger.Client) error { fc.mod.LoadTypeDef(fn.ReturnType) for _, arg := range fn.Args { fc.mod.LoadTypeDef(arg.TypeDef) } for _, arg := range fn.Args { _, err := arg.AddFlag(cmd.Flags(), dag) if err != nil { return err } if !arg.TypeDef.Optional { cmd.MarkFlagRequired(arg.FlagName()) } } if fc.BeforeParse != nil { if err := fc.BeforeParse(fc, cmd, fn); err != nil { return err
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
} } if err := cmd.ParseFlags(cmdArgs); err != nil { return cmd.FlagErrorFunc()(cmd, err) } help, _ := cmd.Flags().GetBool("help") if !help { if err := cmd.ValidateRequiredFlags(); err != nil { return err } if err := cmd.ValidateFlagGroups(); err != nil { return err } } return nil } selectFunc adds the function selection to the query. Note that the type can change if there's an extra selection for supported types. func (fc *FuncCommand) selectFunc(selectName string, fn *modFunction, cmd *cobra.Command, dag *dagger.Client) error { fc.Select(selectName) for _, arg := range fn.Args { var val any flag := cmd.Flags().Lookup(arg.FlagName()) if flag == nil { return fmt.Errorf("no flag for %q", arg.FlagName()) } if arg.TypeDef.Optional && !flag.Changed {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/functions.go
continue } val = flag.Value switch v := val.(type) { case DaggerValue: obj, err := v.Get(cmd.Context(), dag) if err != nil { return fmt.Errorf("failed to get value for argument %q: %w", arg.Name, err) } if obj == nil { return fmt.Errorf("no value for argument: %s", arg.Name) } val = obj case pflag.SliceValue: val = v.GetSlice() } fc.Arg(arg.Name, val) } return nil } func (fc *FuncCommand) Select(name string) { if fc.q == nil { fc.q = querybuilder.Query() } fc.q = fc.q.Select(gqlFieldName(name)) } func (fc *FuncCommand) Arg(name string, value any) { fc.q = fc.q.Arg(gqlArgName(name), value) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/main.go
package main import ( "fmt" "io" "os" "path/filepath" "runtime/pprof" "runtime/trace" "github.com/dagger/dagger/tracing" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) var ( workdir string cpuprofile string pprofAddr string debug bool ) func init() { logrus.StandardLogger().SetOutput(io.Discard) rootCmd.PersistentFlags().StringVar(&workdir, "workdir", ".", "The host workdir loaded into dagger") rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "Show more information for debugging") rootCmd.PersistentFlags().StringVar(&cpuprofile, "cpuprofile", "", "collect CPU profile to path, and trace at path.trace") rootCmd.PersistentFlags().StringVar(&pprofAddr, "pprof", "", "serve HTTP pprof at this address")
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/main.go
rootCmd.AddCommand( listenCmd, versionCmd, queryCmd, runCmd, moduleCmd, sessionCmd(), genDocCmd, downloadCmd, upCmd, shellCmd, ) funcCmds.AddParent(rootCmd) cobra.AddTemplateFunc("isExperimental", isExperimental) rootCmd.SetUsageTemplate(usageTemplate) rootCmd.AddGroup(moduleGroup) } var rootCmd = &cobra.Command{ Use: "dagger", Short: "The Dagger CLI provides a command-line interface to Dagger.", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true if cpuprofile != "" { profF, err := os.Create(cpuprofile) if err != nil { return fmt.Errorf("create profile: %w", err) } pprof.StartCPUProfile(profF)
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/main.go
tracePath := cpuprofile + ".trace" traceF, err := os.Create(tracePath) if err != nil { return fmt.Errorf("create trace: %w", err) } if err := trace.Start(traceF); err != nil { return fmt.Errorf("start trace: %w", err) } } if pprofAddr != "" { if err := setupDebugHandlers(pprofAddr); err != nil { return fmt.Errorf("start pprof: %w", err) } } var err error workdir, err = NormalizeWorkdir(workdir) if err != nil { return err } if err := os.Chdir(workdir); err != nil { return err } return nil }, PersistentPostRun: func(cmd *cobra.Command, args []string) { pprof.StopCPUProfile() trace.Stop() }, } func main() {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/main.go
closer := tracing.Init() if err := rootCmd.Execute(); err != nil { closer.Close() os.Exit(1) } closer.Close() } func NormalizeWorkdir(workdir string) (string, error) { if workdir == "" { workdir = os.Getenv("DAGGER_WORKDIR") } if workdir == "" { var err error workdir, err = os.Getwd() if err != nil { return "", err } } workdir, err := filepath.Abs(workdir) if err != nil { return "", err } return workdir, nil } func isExperimental(cmd *cobra.Command) bool {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/main.go
if _, ok := cmd.Annotations["experimental"]; ok { return true } var experimental bool cmd.VisitParents(func(cmd *cobra.Command) { if _, ok := cmd.Annotations["experimental"]; ok { experimental = true return } }) return experimental } const usageTemplate = `Usage: {{- if .Runnable}} {{.UseLine}} {{- end}} {{- if .HasAvailableSubCommands}} {{ .CommandPath}} [command] {{- end}}
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/main.go
{{- if gt (len .Aliases) 0}} Aliases: {{.NameAndAliases}} {{- end}} {{- if isExperimental .}} EXPERIMENTAL: {{.CommandPath}} is currently under development and may change in the future. {{- end}} {{- if .HasExample}} Examples: {{ .Example }} {{- end}} {{- if .HasAvailableSubCommands}}{{$cmds := .Commands}} {{- if eq (len .Groups) 0}} Available Commands: {{- range $cmds }} {{- if (or .IsAvailableCommand (eq .Name "help"))}} {{rpad .Name .NamePadding }} {{.Short}} {{- end}} {{- end}} {{- else}} {{- range $group := .Groups}} {{.Title}}: {{- range $cmds }} {{- if (and (eq .GroupID $group.ID) (or .IsAvailableCommand (eq .Name "help")))}} {{rpad .Name .NamePadding }} {{.Short}} {{- end}} {{- end}}{{/* range $cmds */}} {{- end}}{{/* range $group := .Groups */}} {{- if not .AllChildCommandsHaveGroup}}
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/main.go
Additional Commands: {{- range $cmds }} {{- if (and (eq .GroupID "") (or .IsAvailableCommand (eq .Name "help")))}} {{rpad .Name .NamePadding }} {{.Short}} {{- end}} {{- end}}{{/* range $cmds */}} {{- end}}{{/* if not .AllChildCommandsHaveGroup */}} {{- end}}{{/* if eq (len .Groups) 0 */}} {{- end}}{{/* if .HasAvailableSubCommands */}} {{- if .HasAvailableLocalFlags}} Flags: {{ .LocalFlags.FlagUsages | trimTrailingWhitespaces}} {{- end}} {{- if .HasAvailableInheritedFlags}} Global Flags: {{ .InheritedFlags.FlagUsages | trimTrailingWhitespaces}} {{- end}} {{- if .HasHelpSubCommands}} Additional help topics: {{- range .Commands}} {{- if .IsAdditionalHelpTopicCommand}} {{rpad .CommandPath .CommandPathPadding}} {{.Short}} {{- end}} {{- end}} {{- end}}{{/* if .HasHelpSubCommands */}} {{- if .HasAvailableSubCommands }} Use "{{.CommandPath}} [command] --help" for more information about a command. {{- end}} `
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
package main import ( "context" "encoding/json" "fmt" "net/http" "net/url" "os" "path"
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
"path/filepath" "strings" "dagger.io/dagger" "github.com/dagger/dagger/core/modules" "github.com/dagger/dagger/engine/client" "github.com/go-git/go-git/v5" "github.com/iancoleman/strcase" "github.com/juju/ansiterm/tabwriter" "github.com/moby/buildkit/util/gitutil" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/vito/progrock" ) var ( moduleGroup = &cobra.Group{ ID: "module", Title: "Dagger Modules (Experimental)", } moduleURL string moduleFlags = pflag.NewFlagSet("module", pflag.ContinueOnError) sdk string licenseID string moduleName string installName string force bool ) const ( moduleURLDefault = "." ) func init() {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
moduleFlags.StringVarP(&moduleURL, "mod", "m", "", "Path to dagger.json config file for the module or a directory containing that file. Either local path (e.g. \"/path/to/some/dir\") or a github repo (e.g. \"github.com/dagger/dagger/path/to/some/subdir\")") moduleFlags.BoolVar(&focus, "focus", true, "Only show output for focused commands") moduleCmd.PersistentFlags().AddFlagSet(moduleFlags) listenCmd.PersistentFlags().AddFlagSet(moduleFlags) queryCmd.PersistentFlags().AddFlagSet(moduleFlags) funcCmds.AddFlagSet(moduleFlags) moduleInitCmd.Flags().StringVar(&sdk, "sdk", "", "SDK name or image ref to use for the module") moduleInitCmd.Flags().StringVar(&moduleName, "name", "", "Name of the new module") moduleInitCmd.Flags().StringVar(&licenseID, "license", "", "License identifier to generate - see https:spdx.org/licenses/") moduleInitCmd.MarkFlagsRequiredTogether("sdk", "name") modulePublishCmd.Flags().BoolVarP(&force, "force", "f", false, "Force publish even if the git repository is not clean") moduleInstallCmd.Flags().StringVarP(&installName, "name", "n", "", "Name to use for the dependency in the module. Defaults to the name of the module being installed.") moduleCmd.AddCommand(moduleInitCmd) moduleCmd.AddCommand(moduleInstallCmd) moduleCmd.AddCommand(moduleSyncCmd) moduleCmd.AddCommand(modulePublishCmd) } var moduleCmd = &cobra.Command{ Use: "module", Aliases: []string{"mod"}, Short: "Manage Dagger modules", Long: "Manage Dagger modules. By default, print the configuration of the specified module in json format.", Example: strings.TrimSpace(` dagger mod -m /path/to/some/dir dagger mod -m github.com/dagger/hello-dagger `, ), GroupID: moduleGroup.ID,
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
Annotations: map[string]string{ "experimental": "true", }, RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() return withEngineAndTUI(ctx, client.Params{}, func(ctx context.Context, engineClient *client.Client) (err error) { modConf, err := getDefaultModuleConfiguration(ctx, engineClient.Dagger(), "") if err != nil { return fmt.Errorf("failed to load module: %w", err) } if !modConf.FullyInitialized() { return fmt.Errorf("module must be fully initialized") } mod := modConf.Mod name, err := mod.Name(ctx) if err != nil { return fmt.Errorf("failed to get module name: %w", err) } sdk, err := mod.SDK(ctx) if err != nil { return fmt.Errorf("failed to get module SDK: %w", err) } depMods, err := mod.Dependencies(ctx) if err != nil { return fmt.Errorf("failed to get module dependencies: %w", err) } var depModNames []string for _, depMod := range depMods { depModName, err := depMod.Name(ctx) if err != nil {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
return fmt.Errorf("failed to get module name: %w", err) } depModNames = append(depModNames, depModName) } tw := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 0, 3, ' ', tabwriter.DiscardEmptyColumns) fmt.Fprintf(tw, "%s\t%s\n", "Name:", name, ) fmt.Fprintf(tw, "%s\t%s\n", "SDK:", sdk, ) fmt.Fprintf(tw, "%s\t%s\n", "Root Directory:", modConf.LocalRootPath, ) fmt.Fprintf(tw, "%s\t%s\n", "Source Directory:", modConf.LocalSourcePath, ) fmt.Fprintf(tw, "%s\t%s\n", "Dependencies:", strings.Join(depModNames, ", "), ) return tw.Flush() }) }, } var moduleInitCmd = &cobra.Command{
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
Use: "init [--sdk string --name string]", Short: "Initialize a new Dagger module", Long: "Initialize a new Dagger module in a local directory.", Example: "dagger mod init --name=hello --sdk=python", RunE: func(cmd *cobra.Command, _ []string) (rerr error) { ctx := cmd.Context() return withEngineAndTUI(ctx, client.Params{}, func(ctx context.Context, engineClient *client.Client) (err error) { dag := engineClient.Dagger() cwd, err := os.Getwd() if err != nil { return fmt.Errorf("failed to get current working directory: %w", err) } modConf, err := getDefaultModuleConfiguration(ctx, dag, cwd) if err != nil { return fmt.Errorf("failed to get configured module: %w", err) } if modConf.SourceKind != dagger.LocalSource { return fmt.Errorf("module must be local") } if modConf.ModuleSourceConfigExists { return fmt.Errorf("module already exists") } _, err = modConf.Mod. WithName(moduleName). WithSDK(sdk). GeneratedSourceRootDirectory(). Export(ctx, modConf.LocalRootPath) if err != nil { return fmt.Errorf("failed to generate code: %w", err)
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
} if err := findOrCreateLicense(ctx, modConf.LocalSourcePath); err != nil { return err } return nil }) }, } var moduleInstallCmd = &cobra.Command{ Use: "install [flags] MODULE", Aliases: []string{"use"}, Short: "Add a new dependency to a Dagger module", Long: "Add a Dagger module as a dependency of a local module.", Example: "dagger mod install github.com/shykes/daggerverse/ttlsh@16e40ec244966e55e36a13cb6e1ff8023e1e1473", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, extraArgs []string) (rerr error) { ctx := cmd.Context() return withEngineAndTUI(ctx, client.Params{}, func(ctx context.Context, engineClient *client.Client) (err error) { dag := engineClient.Dagger() modConf, err := getDefaultModuleConfiguration(ctx, dag, "") if err != nil { return fmt.Errorf("failed to get configured module: %w", err) } if modConf.SourceKind != dagger.LocalSource { return fmt.Errorf("module must be local") } if !modConf.FullyInitialized() { return fmt.Errorf("module must be fully initialized, root directory initialized: %t, source directory initialized: %t", modConf.ModuleRootConfigExists, modConf.ModuleSourceConfigExists) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
depRefStr := extraArgs[0] depSrc := dag.ModuleSource(depRefStr) depSrcKind, err := depSrc.Kind(ctx) if err != nil { return fmt.Errorf("failed to get module ref kind: %w", err) } if depSrcKind == dagger.LocalSource { depAbsPath, err := filepath.Abs(depRefStr) if err != nil { return fmt.Errorf("failed to get absolute path for %s: %w", depRefStr, err) } depRelPath, err := filepath.Rel(modConf.LocalSourcePath, depAbsPath) if err != nil { return fmt.Errorf("failed to get relative path: %w", err) } depSrc = dag.ModuleSource(depRelPath) } dep := dag.ModuleDependency(depSrc, dagger.ModuleDependencyOpts{ Name: installName, }) _, err = modConf.Mod. WithDependencies([]*dagger.ModuleDependency{dep}). GeneratedSourceRootDirectory(). Export(ctx, modConf.LocalRootPath) if err != nil { return fmt.Errorf("failed to generate code: %w", err) } return nil })
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
}, } var moduleSyncCmd = &cobra.Command{ Use: "sync", Short: "Synchronize a Dagger module", Long: `Synchronize a Dagger module with the latest version of its extensions. :::note This is only required for IDE auto-completion/LSP purposes. ::: This command re-regerates the module's generated code based on dependencies and the current state of the module's source code. `, RunE: func(cmd *cobra.Command, extraArgs []string) (rerr error) { ctx := cmd.Context() return withEngineAndTUI(ctx, client.Params{}, func(ctx context.Context, engineClient *client.Client) (err error) { dag := engineClient.Dagger() modConf, err := getDefaultModuleConfiguration(ctx, dag, "") if err != nil { return fmt.Errorf("failed to get configured module: %w", err) } if modConf.SourceKind != dagger.LocalSource { return fmt.Errorf("module must be local") } _, err = modConf.Mod.GeneratedSourceRootDirectory().Export(ctx, modConf.LocalRootPath) if err != nil { return fmt.Errorf("failed to generate code: %w", err) } return nil }) },
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
} const daDaggerverse = "https:daggerverse.dev" var modulePublishCmd = &cobra.Command{ Use: "publish", Short: "Publish a Dagger module to the Daggerverse", Long: fmt.Sprintf(`Publish a local module to the Daggerverse (%s). The module needs to be committed to a git repository and have a remote configured with name "origin". The git repository must be clean (unless forced), to avoid mistakingly depending on uncommitted files. `, daDaggerverse, ), RunE: func(cmd *cobra.Command, extraArgs []string) (rerr error) { ctx := cmd.Context() return withEngineAndTUI(ctx, client.Params{}, func(ctx context.Context, engineClient *client.Client) (err error) { rec := progrock.FromContext(ctx) vtx := rec.Vertex("publish", strings.Join(os.Args, " "), progrock.Focused()) defer func() { vtx.Done(err) }() cmd.SetOut(vtx.Stdout()) cmd.SetErr(vtx.Stderr()) dag := engineClient.Dagger() modConf, err := getDefaultModuleConfiguration(ctx, dag, "") if err != nil { return fmt.Errorf("failed to get configured module: %w", err) } if modConf.SourceKind != dagger.LocalSource { return fmt.Errorf("module must be local") } if !modConf.FullyInitialized() { return fmt.Errorf("module must be fully initialized")
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
} repo, err := git.PlainOpenWithOptions(modConf.LocalSourcePath, &git.PlainOpenOptions{ DetectDotGit: true, }) if err != nil { return fmt.Errorf("failed to open git repo: %w", err) } wt, err := repo.Worktree() if err != nil { return fmt.Errorf("failed to get git worktree: %w", err) } st, err := wt.Status() if err != nil { return fmt.Errorf("failed to get git status: %w", err) } head, err := repo.Head() if err != nil { return fmt.Errorf("failed to get git HEAD: %w", err) } commit := head.Hash() rec.Debug("git commit", progrock.Labelf("commit", commit.String())) orig, err := repo.Remote("origin") if err != nil { return fmt.Errorf("failed to get git remote: %w", err) } refPath, err := originToPath(orig.Config().URLs[0]) if err != nil { return fmt.Errorf("failed to get module path: %w", err) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
gitRoot := wt.Filesystem.Root() pathFromRoot, err := filepath.Rel(gitRoot, modConf.LocalSourcePath) if err != nil { return fmt.Errorf("failed to get path from git root: %w", err) } if !st.IsClean() && !force { cmd.Println(st) return fmt.Errorf("git repository is not clean; run with --force to ignore") } refStr := fmt.Sprintf("%s@%s", path.Join(refPath, pathFromRoot), commit) crawlURL, err := url.JoinPath(daDaggerverse, "crawl") if err != nil { return fmt.Errorf("failed to get module URL: %w", err) } data := url.Values{} data.Add("ref", refStr) req, err := http.NewRequest(http.MethodPut, crawlURL, strings.NewReader(data.Encode())) if err != nil { return fmt.Errorf("failed to create request: %w", err) } req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
res, err := http.DefaultClient.Do(req) if err != nil { return fmt.Errorf("failed to get module: %w", err) } cmd.Println("Publishing", refStr, "to", daDaggerverse+"...") cmd.Println() cmd.Println("You can check on the crawling status here:") cmd.Println() cmd.Println(" " + res.Request.URL.String()) modURL, err := url.JoinPath(daDaggerverse, "mod", refStr) if err != nil { return fmt.Errorf("failed to get module URL: %w", err) } cmd.Println() cmd.Println("Once the crawl is complete, you can view your module here:") cmd.Println() cmd.Println(" " + modURL) return res.Body.Close() }) }, } func originToPath(origin string) (string, error) { url, err := gitutil.ParseURL(origin) if err != nil { return "", fmt.Errorf("failed to parse git remote origin URL: %w", err) } return strings.TrimSuffix(path.Join(url.Host, url.Path), ".git"), nil } type configuredModule struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
Mod *dagger.Module SourceKind dagger.ModuleSourceKind LocalRootPath string LocalSourcePath string ModuleRootConfigExists bool ModuleSourceConfigExists bool } func (c *configuredModule) FullyInitialized() bool { return c.ModuleRootConfigExists && c.ModuleSourceConfigExists } func getDefaultModuleConfiguration(ctx context.Context, dag *dagger.Client, defaultRootPath string) (*configuredModule, error) { srcRefStr := moduleURL if srcRefStr == "" { if v, ok := os.LookupEnv("DAGGER_MODULE"); ok { srcRefStr = v } if srcRefStr == "" { srcRefStr = moduleURLDefault } } return getModuleConfigurationForSourceRef(ctx, dag, srcRefStr, defaultRootPath) } func getModuleConfigurationForSourceRef(
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
ctx context.Context, dag *dagger.Client, srcRefStr string, defaultRootPath string, ) (*configuredModule, error) { conf := &configuredModule{} cwd, err := os.Getwd() if err != nil { return nil, fmt.Errorf("failed to get current working directory: %w", err) } defaultConfigDir, foundDefaultConfig, err := findUp(cwd) if err != nil { return nil, fmt.Errorf("error trying to find config path for %s: %s", cwd, err) } if foundDefaultConfig { configPath := filepath.Join(defaultConfigDir, modules.Filename) contents, err := os.ReadFile(configPath) if err != nil { return nil, fmt.Errorf("failed to read %s: %w", configPath, err) } var modCfg modules.ModuleConfig if err := json.Unmarshal(contents, &modCfg); err != nil {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
return nil, fmt.Errorf("failed to unmarshal %s: %s", configPath, err) } if err := modCfg.Validate(); err != nil { return nil, fmt.Errorf("error validating %s: %s", configPath, err) } if namedDep, ok := modCfg.DependencyByName(srcRefStr); ok { srcRefStr = namedDep.Source } } src := dag.ModuleSource(srcRefStr) conf.SourceKind, err = src.Kind(ctx) if err != nil { return nil, fmt.Errorf("failed to get module ref kind: %w", err) } if conf.SourceKind == dagger.LocalSource { conf.LocalSourcePath, err = filepath.Abs(srcRefStr) if err != nil { return nil, fmt.Errorf("failed to get absolute path for %s: %w", srcRefStr, err) } conf.LocalRootPath, conf.ModuleRootConfigExists, err = findUpRootFor(conf.LocalSourcePath, conf.LocalSourcePath) if err != nil { return nil, fmt.Errorf("error trying to find config path for %s: %s", conf.LocalSourcePath, err) } if !conf.ModuleRootConfigExists { if defaultRootPath == "" { conf.LocalRootPath = conf.LocalSourcePath } else {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
defaultRelPath, err := filepath.Rel(conf.LocalRootPath, defaultRootPath) if err != nil { return nil, fmt.Errorf("failed to get relative path: %s", err) } if !filepath.IsLocal(defaultRelPath) { return nil, fmt.Errorf("default module root directory %s escapes git root %s", cwd, conf.LocalRootPath) } conf.LocalRootPath = cwd } } src, conf.ModuleSourceConfigExists, err = loadLocalModuleSource(dag, conf.LocalRootPath, conf.LocalSourcePath) if err != nil { return nil, fmt.Errorf("error loading local module: %s", err) } if !conf.ModuleRootConfigExists && conf.ModuleSourceConfigExists && defaultRootPath == "" { conf.ModuleRootConfigExists = true } conf.Mod = src.AsModule() } else { conf.Mod = src.AsModule() conf.ModuleRootConfigExists = true conf.ModuleSourceConfigExists = true } return conf, nil } func loadLocalModuleSource(
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
dag *dagger.Client, sourceRootAbsPath string, sourceSubdirAbsPath string, ) (*dagger.ModuleSource, bool, error) { var include []string var exclude []string var exists bool configPath := filepath.Join(sourceSubdirAbsPath, modules.Filename) configBytes, err := os.ReadFile(configPath)
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
switch { case err == nil: var modCfg modules.ModuleConfig if err := json.Unmarshal(configBytes, &modCfg); err != nil { return nil, false, fmt.Errorf("error unmarshaling %s: %s", configPath, err) } if err := modCfg.Validate(); err != nil { return nil, false, fmt.Errorf("error validating %s: %s", configPath, err) } include = modCfg.Include exclude = modCfg.Exclude exists = true case os.IsNotExist(err): default: return nil, false, fmt.Errorf("error reading config %s: %s", configPath, err) } sourceSubdirRelPath, err := filepath.Rel(sourceRootAbsPath, sourceSubdirAbsPath) if err != nil { return nil, false, err } return dag.ModuleSource(sourceSubdirRelPath, dagger.ModuleSourceOpts{ RootDirectory: dag.Host().Directory(sourceRootAbsPath, dagger.HostDirectoryOpts{ Include: include, Exclude: exclude, }), }), exists, nil } func findUp(curDirPath string) (string, bool, error) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
if !filepath.IsAbs(curDirPath) { return "", false, fmt.Errorf("path is not absolute: %s", curDirPath) } configPath := filepath.Join(curDirPath, modules.Filename) stat, err := os.Lstat(configPath) switch { case os.IsNotExist(err): case err == nil: if !stat.Mode().IsRegular() { return "", false, fmt.Errorf("expected %s to be a file", configPath) } return curDirPath, true, nil default: return "", false, fmt.Errorf("failed to lstat %s: %s", configPath, err) } if curDirPath == "/" { return curDirPath, false, nil } _, err = os.Lstat(filepath.Join(curDirPath, ".git")) if err == nil { return curDirPath, false, nil } parentDirPath := filepath.Dir(curDirPath) return findUp(parentDirPath) } func findUpRootFor(curDirPath string, sourceSubpath string) (string, bool, error) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
foundDir, found, err := findUp(curDirPath) if err != nil { return "", false, err } if !found { return foundDir, false, nil } configPath := filepath.Join(foundDir, modules.Filename) contents, err := os.ReadFile(configPath) if err != nil { return "", false, fmt.Errorf("failed to read %s: %s", configPath, err) } var modCfg modules.ModuleConfig if err := json.Unmarshal(contents, &modCfg); err != nil { return "", false, fmt.Errorf("failed to unmarshal %s: %s", configPath, err) } if err := modCfg.Validate(); err != nil { return "", false, fmt.Errorf("error validating %s: %s", configPath, err) } sourceRelSubpath, err := filepath.Rel(curDirPath, sourceSubpath) if err != nil { return "", false, fmt.Errorf("failed to get relative path: %s", err) } if modCfg.IsRootFor(sourceRelSubpath) { return curDirPath, true, nil } return findUpRootFor(filepath.Dir(foundDir), sourceSubpath) } func optionalModCmdWrapper(
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
fn func(context.Context, *client.Client, *dagger.Module, *cobra.Command, []string) error, presetSecretToken string, ) func(*cobra.Command, []string) error { return func(cmd *cobra.Command, cmdArgs []string) error { return withEngineAndTUI(cmd.Context(), client.Params{ SecretToken: presetSecretToken, }, func(ctx context.Context, engineClient *client.Client) (err error) { rec := progrock.FromContext(ctx) vtx := rec.Vertex("cmd-loader", strings.Join(os.Args, " ")) defer func() { vtx.Done(err) }() modConf, err := getDefaultModuleConfiguration(ctx, engineClient.Dagger(), "") if err != nil { return fmt.Errorf("failed to get configured module: %w", err) } var loadedMod *dagger.Module if modConf.FullyInitialized() { loadedMod = modConf.Mod.Initialize() load := vtx.Task("loading module") _, err := loadedMod.Serve(ctx) load.Done(err) if err != nil { return fmt.Errorf("failed to serve module: %w", err) } } return fn(ctx, engineClient, loadedMod, cmd, cmdArgs) }) } } func loadModTypeDefs(ctx context.Context, dag *dagger.Client, mod *dagger.Module) (*moduleDef, error) { var res struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
TypeDefs []*modTypeDef } const query = ` fragment TypeDefRefParts on TypeDef { kind optional asObject { name } asInterface { name } asInput { name } asList { elementTypeDef { kind asObject { name } asInterface { name }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
asInput { name } } } } fragment FunctionParts on Function { name description returnType { ...TypeDefRefParts } args { name description defaultValue typeDef { ...TypeDefRefParts } } } fragment FieldParts on FieldTypeDef { name description typeDef { ...TypeDefRefParts } } query TypeDefs($module: ModuleID!) { typeDefs: currentTypeDefs {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
kind optional asObject { name sourceModuleName constructor { ...FunctionParts } functions { ...FunctionParts } fields { ...FieldParts } } asInterface { name sourceModuleName functions { ...FunctionParts } } asInput { name fields { ...FieldParts } } } }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
` err := dag.Do(ctx, &dagger.Request{ Query: query, Variables: map[string]interface{}{ "module": mod, }, }, &dagger.Response{ Data: &res, }) if err != nil { return nil, fmt.Errorf("query module objects: %w", err) } name, err := mod.Name(ctx) if err != nil { return nil, fmt.Errorf("get module name: %w", err) } modDef := &moduleDef{Name: name} for _, typeDef := range res.TypeDefs { switch typeDef.Kind { case dagger.ObjectKind: modDef.Objects = append(modDef.Objects, typeDef) case dagger.InterfaceKind: modDef.Interfaces = append(modDef.Interfaces, typeDef) case dagger.InputKind: modDef.Inputs = append(modDef.Inputs, typeDef) } } return modDef, nil } type moduleDef struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
Name string Objects []*modTypeDef Interfaces []*modTypeDef Inputs []*modTypeDef } func (m *moduleDef) AsFunctionProviders() []functionProvider { providers := make([]functionProvider, 0, len(m.Objects)+len(m.Interfaces)) for _, obj := range m.AsObjects() { providers = append(providers, obj) } for _, iface := range m.AsInterfaces() { providers = append(providers, iface) } return providers } func (m *moduleDef) AsObjects() []*modObject { var defs []*modObject for _, typeDef := range m.Objects { if typeDef.AsObject != nil { defs = append(defs, typeDef.AsObject) } } return defs } func (m *moduleDef) AsInterfaces() []*modInterface { var defs []*modInterface
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
for _, typeDef := range m.Interfaces { if typeDef.AsInterface != nil { defs = append(defs, typeDef.AsInterface) } } return defs } func (m *moduleDef) AsInputs() []*modInput { var defs []*modInput for _, typeDef := range m.Inputs { if typeDef.AsInput != nil { defs = append(defs, typeDef.AsInput) } } return defs } func (m *moduleDef) GetObject(name string) *modObject { for _, obj := range m.AsObjects() { if gqlObjectName(obj.Name) == gqlObjectName(name) { return obj } } return nil } func (m *moduleDef) GetInterface(name string) *modInterface { for _, iface := range m.AsInterfaces() { if gqlObjectName(iface.Name) == gqlObjectName(name) { return iface
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
} } return nil } func (m *moduleDef) GetFunctionProvider(name string) functionProvider { if obj := m.GetObject(name); obj != nil { return obj } if iface := m.GetInterface(name); iface != nil { return iface } return nil } func (m *moduleDef) GetInput(name string) *modInput { for _, input := range m.AsInputs() { if gqlObjectName(input.Name) == gqlObjectName(name) { return input } } return nil } func (m *moduleDef) GetMainObject() *modObject { return m.GetObject(m.Name) } func (m *moduleDef) LoadTypeDef(typeDef *modTypeDef) { if typeDef.AsObject != nil && typeDef.AsObject.Functions == nil && typeDef.AsObject.Fields == nil { obj := m.GetObject(typeDef.AsObject.Name) if obj != nil { typeDef.AsObject = obj
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
} } if typeDef.AsInterface != nil && typeDef.AsInterface.Functions == nil { iface := m.GetInterface(typeDef.AsInterface.Name) if iface != nil { typeDef.AsInterface = iface } } if typeDef.AsInput != nil && typeDef.AsInput.Fields == nil { input := m.GetInput(typeDef.AsInput.Name) if input != nil { typeDef.AsInput = input } } if typeDef.AsList != nil { m.LoadTypeDef(typeDef.AsList.ElementTypeDef) } } type modTypeDef struct { Kind dagger.TypeDefKind Optional bool AsObject *modObject AsInterface *modInterface AsInput *modInput AsList *modList } type functionProvider interface { ProviderName() string GetFunctions() []*modFunction GetFunction(name string) (*modFunction, error)
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
} func (t *modTypeDef) Name() string { if t.AsObject != nil { return t.AsObject.Name } if t.AsInterface != nil { return t.AsInterface.Name } return "" } func (t *modTypeDef) AsFunctionProvider() functionProvider { if t.AsObject != nil { return t.AsObject } if t.AsInterface != nil { return t.AsInterface } return nil } type modObject struct { Name string Functions []*modFunction Fields []*modField Constructor *modFunction SourceModuleName string } var _ functionProvider = (*modObject)(nil) func (o *modObject) ProviderName() string { return o.Name }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
func (o *modObject) GetFunctions() []*modFunction { fns := make([]*modFunction, 0, len(o.Functions)+len(o.Fields)) for _, f := range o.Fields { fns = append(fns, &modFunction{ Name: f.Name, Description: f.Description, ReturnType: f.TypeDef, }) } fns = append(fns, o.Functions...) return fns } func (o *modObject) GetFunction(name string) (*modFunction, error) { for _, fn := range o.Functions { if fn.Name == name || cliName(fn.Name) == name { return fn, nil } } for _, f := range o.Fields { if f.Name == name || cliName(f.Name) == name { return &modFunction{ Name: f.Name, Description: f.Description, ReturnType: f.TypeDef, }, nil } } return nil, fmt.Errorf("no function '%s' in object type '%s'", name, o.Name) } type modInterface struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
Name string Functions []*modFunction } var _ functionProvider = (*modInterface)(nil) func (o *modInterface) ProviderName() string { return o.Name } func (o *modInterface) GetFunctions() []*modFunction { fns := make([]*modFunction, 0, len(o.Functions)) fns = append(fns, o.Functions...) return fns } func (o *modInterface) GetFunction(name string) (*modFunction, error) { for _, fn := range o.Functions { if fn.Name == name || cliName(fn.Name) == name { return fn, nil } } return nil, fmt.Errorf("no function '%s' in interface type '%s'", name, o.Name) } type modInput struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
Name string Fields []*modField } type modList struct { ElementTypeDef *modTypeDef } type modField struct { Name string Description string TypeDef *modTypeDef } type modFunction struct { Name string Description string ReturnType *modTypeDef Args []*modFunctionArg } type modFunctionArg struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/module.go
Name string Description string TypeDef *modTypeDef DefaultValue dagger.JSON flagName string } func (r *modFunctionArg) FlagName() string { if r.flagName == "" { r.flagName = cliName(r.Name) } return r.flagName } func getDefaultValue[T any](r *modFunctionArg) (T, error) { var val T err := json.Unmarshal([]byte(r.DefaultValue), &val) return val, err } func gqlObjectName(name string) string { return strcase.ToCamel(name) } func gqlFieldName(name string) string { return strcase.ToLowerCamel(name) } func gqlArgName(name string) string { return strcase.ToLowerCamel(name) } func cliName(name string) string { return strcase.ToKebab(name) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/query.go
package main import ( "context" "encoding/json" "fmt" "io" "os" "strings" "dagger.io/dagger" "github.com/dagger/dagger/engine/client" "github.com/spf13/cobra" "github.com/vito/progrock" "golang.org/x/term" ) var ( queryFile string
closed
dagger/dagger
https://github.com/dagger/dagger
6,358
CLI: improve display of core API in `--help` output
https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`. There's most likely going to be a lot of little things needed to address this, possibly including but not limited to: 1. displaying multi-line doc strings better 2. sorting of functions more cleanly I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though.
https://github.com/dagger/dagger/issues/6358
https://github.com/dagger/dagger/pull/6549
7a63c3d019530d1f08b2f72cc28e753d99b5896d
7c0ee45d762719005fad5981d41b038811ebb7f6
2024-01-03T20:03:17Z
go
2024-02-01T14:32:43Z
cmd/dagger/query.go
queryVarsInput []string queryVarsJSONInput string ) var queryCmd = &cobra.Command{ Use: "query [flags] [OPERATION]", Aliases: []string{"q"}, Short: "Send API queries to a dagger engine", Long: `Send API queries to a dagger engine. When no document file is provided, reads query from standard input. Can optionally provide the GraphQL operation name if there are multiple queries in the document. `, Example: `dagger query <<EOF { container { from(address:"hello-world") { withExec(args:["/hello"]) { stdout } } } } EOF `, Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { return optionalModCmdWrapper(Query, "")(cmd, args) }, } func Query(ctx context.Context, engineClient *client.Client, _ *dagger.Module, _ *cobra.Command, args []string) (rerr error) {