Coder Social home page Coder Social logo

Comments (10)

Marak avatar Marak commented on June 12, 2024

The Array type isn't supported yet in commandful

As for relationships, they are half implemented. It should be possible to use relational resources and set the foreign key via the prompt. What should be added is an additional prompt to create a new relational resource, versus having to manually set and get the ids through two commands.

Should be easy to add both, just haven't gotten around to it yet.

from commandful.

nrw avatar nrw commented on June 12, 2024

Thanks for the quick response. I'll hold my breath waiting for the new features. :)

from commandful.

Marak avatar Marak commented on June 12, 2024

@nrw - What behavior are you trying to get out of the Array type?

Are you trying to store an array of strings, or are you trying to create a relationship between two resources and store an array of objects?

from commandful.

nrw avatar nrw commented on June 12, 2024

In the example above, I'm trying to store an array of strings.

I'd certainly like to have an interface for adding children, too. You said relationships are partially implemented. Is this piece done? I'd love to see an example use.

from commandful.

Marak avatar Marak commented on June 12, 2024

@nrw - Understood. I'm working on both right now.

Trying to determine the best user-experience for the case of adding items to an Array.

I'm thinking, it should continually prompt for new values until the user types a special word like done or stop. Not sure of another way it could work that would make sense.

from commandful.

nrw avatar nrw commented on June 12, 2024

In the interest of avoiding reserving a word, here's a thought:

If the user submits a blank value, prompt something to this effect:

(a)dd an empty string to this array? or are you (d)one entering values? [d]:

Is that a better idea?

from commandful.

Marak avatar Marak commented on June 12, 2024

Was my first thought. I dislike that because it increases the amount of reading and key-strokes by a factor of three.

The reserved word could be an empty value. I'll roll with this idea and see how it feels. If it doesn't work I might go back and do a menu option instead.

Thanks.

from commandful.

Marak avatar Marak commented on June 12, 2024

Created ticket in prompt for array type flatiron/prompt#54

from commandful.

nrw avatar nrw commented on June 12, 2024

I'm glad to try whatever you come up with. :)

Some thoughts about the interface (i wrote these out for myself and they seemed worth sharing. i'm sure there is a better idea out there.)

No value + enter to stop (plus empty string mapping):

This one seems like the best option (to me). You map something like '' and/or "" to store an empty string. It's way easier to read on screen than other options and only prevents a really unusual value.

$ app group create
warn:    prompting user for data
info:    define new group
prompt: id:  group1
prompt: people: add item: sam
prompt: people: add item: ''
prompt: people: add item: <enter>
info: created group

enter twice to stop:

This way results in one less keystroke, but way more text on the screen.

$ app group create
warn:    prompting user for data
info:    define new group
prompt: id:  group1
prompt: people: add item: sam
prompt: people: add item: <enter>
prompt: people: (a)dd empty string? or be (d)one [d]: a <enter>
prompt: people: add item: <enter>
prompt: people: (a)dd empty string? or be (d)one [d]: <enter>
info: created group

done + enter to stop:

This way doesn't let you use the word done as an array value

$ app group create
warn:    prompting user for data
info:    define new group
prompt: id:  group1
prompt: people: add item: sam
prompt: people: add item: <enter>
prompt: people: add item: done
info: created group

No value + enter to stop:

This way doesn't let you set an empty string as an array value.

$ app group create
warn:    prompting user for data
info:    define new group
prompt: id:  group1
prompt: people: add item: sam
prompt: people: add item: <enter>
info: created group

Ask for add or done intention after each item:

The menu I'm picturing has a lot more key strokes. Do you have something else in mind?

$ app group create
warn:    prompting user for data
info:    define new group
prompt: id:  group1
prompt: people: add or done? [add]: <enter>
prompt: people: add item: sam
prompt: people: add or done? [add]: <enter>
prompt: people: add item: <enter>
prompt: people: add or done? [add]: done
info: created group

from commandful.

Marak avatar Marak commented on June 12, 2024

I've got a good start to adding both of these new features to commandful, but I'm now blocked on both by: flatiron/prompt#54 ( since foreign keys are stored in typed arrays )

Once we clear that issue up I'll pull in the new prompt and push my commandful changes.

from commandful.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.