Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

think deeply about package layout #96

Open
amonks opened this issue Mar 30, 2024 · 1 comment · May be fixed by #134
Open

think deeply about package layout #96

amonks opened this issue Mar 30, 2024 · 1 comment · May be fixed by #134
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@amonks
Copy link
Owner

amonks commented Mar 30, 2024

I don't want to change this ever after 1.0, so I'd like to make sure it's right before releasing that version.

Some considerations:

  • pkg folder is off-trend in 2024
  • "run stuff with dependenices" and "tui" perhaps ought to be separate packages
  • "run is one package" is simple, but is it an uncomfortable precedent?
  • what should be internal? should the tui?
  • where should things like scroll live? their own repo? should logview?
@amonks amonks added enhancement New feature or request needs thought We have some decisions to make before moving on this. labels Mar 30, 2024
@amonks amonks added this to the 1.0 milestone Mar 30, 2024
@amonks amonks changed the title reconsider package layout think deeply about package layout Apr 5, 2024
@amonks amonks self-assigned this Apr 5, 2024
@amonks
Copy link
Owner Author

amonks commented Apr 6, 2024

this feels pretty good to me:

// package tasks

type Task interface {
	Metadata() TaskMetadata
	Start(context.Context, io.Writer) (<-chan struct{}, error) // chan is `ready`
}

type TaskMetadata struct{}

type Tasks struct{}

func (Tasks) Validate() error
func (Tasks) IDs() []string
func (Tasks) Task(id string) Task
func (Tasks) Watches() []string

func (Tasks) Subtree(id string) Tasks

// list of ids where metadata matches the argument
func (Tasks) WithWatch(watch string) []string
func (Tasks) WithDependency(dependency string) []string
func (Tasks) WithTrigger(trigger string) []string
// package script

type Script struct{}

func New(cwd, script string) Script
func (Script) Start(context.Context, io.Writer) error


type ScriptTask struct {
	script   Script
	metadata TaskMetadata
}

var _ Task = ScriptTask{}

func NewScriptTask(Script, TaskMetadata)
func (ScriptTask) CWD() string // so that Tasks.Validate() can check for ../ watches
func (ScriptTask) Metadata() TaskMetadata
func (ScriptTask) Start(context.Context, io.Writer) (<-chan struct{}, error)
// package taskfile

type Taskfile struct{}

func Load(string) (Taskfile, error)
func (Taskfile) Validate() error
func (Taskfile) Tasks() Tasks
// package runner

type Runner struct{}

func New(tasks []Task) Runner
func (Runner) Start(context.Context, MultiWriter, entryPointTaskIDs ...string) error
func (Runner) Add(id string) error     // add more entry-point tasks mid-run
func (Runner) Remove(id string) error  // remove entry-point tasks mid-run
func (Runner) Invalidate(id string) error

func (Runner) Status() map[string]TaskStatus

type MultiWriter interface {
	Writer(id string) io.Writer
}

type TaskStatus int
// package tui

func Start(ctx context.Context, tasks Tasks, entryPointTaskIDs ...string) error
// package printer

type Printer struct{}

var _ MultiWriter = Printer{}

func NewPrinter(gutterWidth int) Printer
func (Printer) Writer(string) io.Writer

@amonks amonks removed the needs thought We have some decisions to make before moving on this. label Apr 6, 2024
amonks added a commit that referenced this issue Apr 18, 2024
closes #96
closes #72
@amonks amonks linked a pull request Apr 18, 2024 that will close this issue
amonks added a commit that referenced this issue Apr 19, 2024
closes #96
closes #72
closes #129

todo:
close #126
close #57
close #139
amonks added a commit that referenced this issue Apr 22, 2024
closes #96
closes #72
closes #129

todo:
close #126
close #57
close #139
@amonks amonks closed this as completed Apr 23, 2024
@amonks amonks reopened this Apr 23, 2024
amonks added a commit that referenced this issue Apr 23, 2024
closes #96
closes #72
closes #129

todo:
close #57
close #139
amonks added a commit that referenced this issue Apr 25, 2024
closes #96
closes #72
closes #129

todo:
close #57
close #139
amonks added a commit that referenced this issue Jul 29, 2024
closes #96
closes #72
closes #129

todo:
close #57
close #139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant