flipper-io / flipper

Flipper is a development platform that can be controlled from any programming language.
https://www.flipper.io/
Apache License 2.0
70 stars 15 forks source link

Console data detectors. #79

Closed georgemorgan closed 7 years ago

georgemorgan commented 7 years ago

The console should accept multiple data detectors for functions that support being sent blocks of data. The three detectors that I can think of right now are strings, URLs, and files. The console should be able to tell the difference between these three when passed to a function, say usart push and determine the appropriate way to push the data the the expectant function.

TravisWhitaker commented 7 years ago

It is already possible to do this with strings and files, although there is no automatic differentiation between strings and files because of the following situation:

$ echo sus > asdf
$ flipper
flipper> usart write "asdf"

Does the console tell the device to send out sus or asdf over the usart? Instead, the console provides write and writefile commands:

$echo sus > asdf
$ flipper
flipper> usart write "asdf" # writes asdf
flipper> usart writefile "asdf" # writes sus

Streaming data to the device from HTTP can already be handled nicely with wget and xargs, so I see no reason to give the console it' own HTTP machinery. For example:

$ wget http://some.url/some/data | xargs flipper usart write
georgemorgan commented 7 years ago

The difference between a file and a string is the extension. If the user wants to send a string, they use quotes. If they want to send a file, they don't use quotes and provide an extension. It is a reasonable limitation not to parse files without extensions.

Users may not have wget installed, or know how to use it with xargs. Windows has no such programs either. We should integrate the ability to fetch content at a URL into the console.

TravisWhitaker commented 7 years ago

There are two issues with the string/file name discrimination scheme you proposed:

Virtually all UNIX environments provide either wget or curl, and Windows has Invoke-WebRequest (which PowerShell provides a wget alias for). This seems like a niche use case anyway, what do you have in mind?

georgemorgan commented 7 years ago

Many users won't know how to use wget. That's the reality of things. I would recommend integrating as much functionality into the console as possible to make it easy for beginners and less of a hassle for more advanced users. I understand the rationale behind writefile, and I think that it is appropriate.

TravisWhitaker commented 7 years ago

What is the use case?

TravisWhitaker commented 7 years ago

When framed in relation to accomplishing the same thing using an interpreted language, it was agreed that there is no use case for this in the present console.

Closing this for now after further discussion with George.