Skip to content

Conversation

ryandoyle
Copy link

This is a proposal to address some of the code architecture and packaging suggestions. It introduces a client module that is the adapter between the HTTP and JSON world and the Go object/structs world.

Test layout is proposed using testify and httptest module which I have prior experience in.

This treatment has been applied to the "resources" sub-command as a demo

An outstanding question is with the JSON mode/pretty mode.

  1. Do we need this?

  2. If so, is this something that should be a formatting-only mode that marshals back from the client object layer?

  3. Depending on 2, this may/may not apply. If we did want to show the underlying full JSON response, then I'd change some of the code architecture. Probably something like.

                FULL JSON MODE       |------------|
               ______________________| Raw client |
              /                      |------------|
    

    |-----------|/ /
    | CLI | /
    |-----------|\ /
    \ |----------------|
    ---| Object Mapping |
    | Client |
    ------------------
    TABLE MODE

Personally, it's probably makes sense to do 2, but is there is value in this being a slightly smarter cURL (question 3)?

This is a proposal to address some of the code architecture and packaging
suggestions. It introduces a client module that is the adapter between
the HTTP and JSON world and the Go object/structs world.

Test layout is proposed using testify and httptest module which I have
prior experience in.

This treatment has been applied to the "resources" sub-command as a demo

An outstanding question is with the JSON mode/pretty mode.

1. Do we need this?

2. If so, is this something that should be a formatting-only mode that
   marshals back from the client object layer?

3. Depending on 2, this may/may not apply. If we did want to show the
   underlying full JSON response, then I'd change some of the code
   architecture. Probably something like.

                   FULL JSON MODE       |------------|
                  ______________________| Raw client |
                 /                      |------------|
   |-----------|/                        /
   |    CLI    |                        /
   |-----------|\                      /
                 \   |----------------|
                  ---| Object Mapping |
                     | Client         |
                     ------------------
                 TABLE MODE

Personally, it's probably makes sense to do 2, but is there is value
in this being a slightly smarter cURL (question 3)?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant