Closed georgemorgan closed 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
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.
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?
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.
What is the use case?
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.
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
, andfiles
. The console should be able to tell the difference between these three when passed to a function, sayusart push
and determine the appropriate way to push the data the the expectant function.