-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b2174b
commit 070b77a
Showing
12 changed files
with
127 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package uml | ||
|
||
import ( | ||
"context" | ||
"io" | ||
) | ||
|
||
type ConverterOptions struct { | ||
MimeType *string | ||
} | ||
|
||
type ConverterOption func(*ConverterOptions) error | ||
|
||
type Converter interface { | ||
From(ctx context.Context, reader io.Reader) (*Spec, error) | ||
} | ||
|
||
type ( | ||
NewConverter func(ConverterOptions) Converter | ||
) | ||
|
||
func WithMimeType(t string) ConverterOption { | ||
return func(opts *ConverterOptions) error { | ||
opts.MimeType = &t | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package uml | ||
|
||
import ( | ||
"context" | ||
"io" | ||
) | ||
|
||
type Generator interface { | ||
Gen(ctx context.Context, spec *Spec, writer io.Writer) error | ||
} | ||
|
||
type GeneratorOptions struct { | ||
Target string | ||
} | ||
|
||
type ( | ||
GeneratorOption func(*GeneratorOptions) error | ||
NewGenerator func(GeneratorOptions) Generator | ||
) | ||
|
||
func WithTarget(t string) GeneratorOption { | ||
return func(opts *GeneratorOptions) error { | ||
opts.Target = t | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package uml | ||
|
||
type Opt[T any] interface { | ||
~func(*T) error | ||
} | ||
|
||
func Apply[T Opt[V], V any](options *V, opts ...T) { | ||
for _, opt := range opts { | ||
if err := opt(options); err != nil { | ||
panic(err) | ||
} | ||
} | ||
} | ||
|
||
func Flat[T Opt[V], V any](opts ...T) T { | ||
return func(o *V) error { | ||
for _, opt := range opts { | ||
if err := opt(o); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
} |
Oops, something went wrong.