Skip to content
This repository has been archived by the owner on Jul 26, 2020. It is now read-only.

Refactor Bake CLI #1

Open
jmickey opened this issue Apr 16, 2019 · 0 comments · May be fixed by #6
Open

Refactor Bake CLI #1

jmickey opened this issue Apr 16, 2019 · 0 comments · May be fixed by #6
Assignees
Labels
enhancement New feature or request in progress Issue is being actively worked on xp/developer Aims to improve the experience for BreadTube developers

Comments

@jmickey
Copy link
Member

jmickey commented Apr 16, 2019

Description

Currently, the bake CLI is both out-of-date with the current state of the repo (see #171), and rather difficult to maintain. In order to improve the situation I have some suggestions and ideas.

App Structure

Moving to the hexagonal architecture pattern for structuring the app. Inspiration and more info can be found in this great talk by @katzien:

Video
Slides
golang-standards/project-layout

I propose moving to the following structure:

bake/
├── cmd/
│   ├── root.go
│   └── other-commands.go
└── pkg/
    ├── creators/
    │   └── creator.go
    └── providers/
        ├── provider.go
        ├── youtube.go
        └── some-other-provider.go

API Design

APIs should provide clear and generic interfaces. In the case of a provider, each provider should have a common set of functions that ensures it conforms to the provider interface. E.g. <provider>.Load(), <provider>.Add(), <provider>.Delete() etc.

Creator will consume providers, with config passed from cmd into the creator.
Example of the code workflow (I haven't tested this code, it's just an idea):

package cmd

import (
  "github.com/breadtubetv/breadtubetv/bake/pkg/creators"
  "github.com/spf13/viper
)

var creator creators.Creator
creator.AddConfig(viper.GetViper())
if creator = creators.Get('slug') == nil {
  // Add a creator if not found
  creator = creator.Create('slug', 'initial-provider', 'url')
}

creator.Providers.Add('twitter')
creator.Provider['twitter'].Update(("followers", 1200000))

...and so on.

This will provide us with an easy way of adding new providers, which can easily be added to creators, which in term can easily be consumed by the CLI.

Implementation

WIP

@jmickey jmickey self-assigned this Apr 16, 2019
@jmickey jmickey transferred this issue from breadtubetv/breadtubetv Apr 18, 2019
@jmickey jmickey linked a pull request Apr 18, 2019 that will close this issue
@jmickey jmickey added enhancement New feature or request in progress Issue is being actively worked on xp/developer Aims to improve the experience for BreadTube developers labels Apr 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request in progress Issue is being actively worked on xp/developer Aims to improve the experience for BreadTube developers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant