Skip to content

upysh: Added rm, rmdir, clear and simplified help #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

upysh: Added rm, rmdir, clear and simplified help #76

wants to merge 3 commits into from

Conversation

robert-hh
Copy link
Contributor

@robert-hh robert-hh commented Jun 4, 2016

  • commands added: rm, rmdir and clear
  • comands simplified: help does not need brackets any more
  • help text rearranged
  • pwd replaces empty string by "/"
  • renamed help to man, to avoid conflicts with the built-in help()
  • show file date & time with ls

- commands added: rm, rmdir and clear
- comands simplified: help does not need brackets any more
- help text rearranged
- pwd replaces empty string by "/"
@robert-hh
Copy link
Contributor Author

Hello Paul. I really love that little script of yours and immediately added it to the Micropython board images. Even if urgently needed on PyBoard and Wipy, I find myself often issuing sh command at the REPL prompt. I polished and extended it a little bit, hopefully in your intent.
Best Regards, Robert

@pfalcon pfalcon force-pushed the master branch 2 times, most recently from 9802eef to ceab4f3 Compare June 10, 2016 21:28
@pfalcon
Copy link
Contributor

pfalcon commented Jun 12, 2016

@robert-hh : Thanks. This contains some good ideas, but I'm not sure they all suitable for upysh as-is and right away. I've added rm, rmdir commands for now. I like an idea to use "man" for help, but people should know it's man, so I've made help to print on module load for now.

But: upysh is intended to be a filesystem shell, so things like "clear" are outside of its scope. It's also intended to be a very minimal shell, so printing date/time are also outside of its scope, at least for now (I find a file size to be a valuable info, and myself almost always pay attention to file size; contrary, I rather rarely consult file's time).

@robert-hh
Copy link
Contributor Author

Hello Paul,
Thanks for the comment. I was unsure about man- Help() collided with the
buitl-in command. But printing it a module start is surely a good
compromise. The 'clear' was requested by someone else. I rarely use it.
But the file date is more a matter of personal preference. I a m using
it as often as the file size, especially when working with data files,
which often have the same size. Then the date gets important. And
together with the PR2160 of Micropython, it can have a meaningful value.
Best Regards, Robert

On 12.06.2016 20:59, Paul Sokolovsky wrote:

@robert-hh https://github.com/robert-hh : Thanks. This contains some
good ideas, but I'm not sure they all suitable for upysh as-is and right
away. I've added rm, rmdir commands for now. I like an idea to use "man"
for help, but people should know it's man, so I've made help to print on
module load for now.

But: upysh is intended to be a filesystem shell, so things like "clear"
are outside of its scope. It's also intended to be a very minimal shell,
so printing date/time are also outside of its scope, at least for now (I
find a file size to be a valuable info, and myself almost always pay
attention to file size; contrary, I rather rarely consult file's time).


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#76 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AL5hxGwoZSk0vo9eKW3yATcaCFSaQyGiks5qLFctgaJpZM4IuKjj.

@dpgeorge
Copy link
Member

I use "clear" a lot and would be +1 on including it. It is related to "file" interaction, eg clearing the screen before cat'ing or ls'ing so you can see things clearly.

@pfalcon
Copy link
Contributor

pfalcon commented Jun 15, 2016

@dpgeorge : Well, if you use it, what can we do? ;-). But mind my concern: I started upysh because I considered @dhylands' upy-shell too big. I don't want it to grow to be just a fork of upy-shell. Of course, any single function, we can add, but it's main purpose is to run on some 2K-heap (where it of course already won't run).

Anyway, are you sure it should be "clear" and not "cls" for example?

@robert-hh
Copy link
Contributor Author

'clear' is the unix/linux command, 'cls' is windows/dos. Since upysh mimics unix, it would be 'clear'. The aspect of RAM usage could be get less important for esp8266, if Damien's PR2067 would get mainstream.

@pfalcon
Copy link
Contributor

pfalcon commented Jun 15, 2016

"cls" is what random human walking down the street would remember about clearing screen, because s/he read a BASIC book somehere in childhood (or for whatever) reason. It's also shorter.

The aspect of RAM usage could be get less important for esp8266, if Damien's PR2067 would get mainstream.

upysh has nothing to do with esp8266, it's just a most minimal to still be useful file shell. Nor any hacks would help it - it itself a hack, made to influence as little as possible anything ride side by side with it. And memory will always be a scarce resource.

@pfalcon
Copy link
Contributor

pfalcon commented Jul 2, 2016

Anyway, are you sure it should be "clear" and not "cls" for example?

@dpgeorge : ping

@pfalcon
Copy link
Contributor

pfalcon commented Jul 3, 2016

I've implemented "man" command now, thanks for the idea, @robert-hh !

@dpgeorge
Copy link
Member

I'd say it should be "clear", since, as @robert-hh says, all other commands are unixy. But if its addition is controversial then don't worry about it.

BTW, if minimal is the goal then making extra clases for, eg, ls, just so you don't need to type parenthesis, seems a bit excessive. But then, balancing minimal with usability is always hard (and I'd say the addition of "clear" is a usability thing).

@robert-hh
Copy link
Contributor Author

When placing upysh into frozen bytecode, the variant with classes uses about 1300 bytes of heap space, whereas a version without classes uses 640 bytes. That's my private copy, which is a little bit larger than Paul's, including clear and date & time on ls. From my previous fights for space I recall, that every class defintion take about 200 bytes of heap. That matches the difference roughly.

@mad474
Copy link
Contributor

mad474 commented Jul 15, 2016

  1. Thank you all for upysh!
  2. Today on a freshly flashed ESP8266:
>>> from upysh import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "upysh.py", line 35, in <module>
AttributeError: 'module' object has no attribute 'rmdir'

... because there's no uos.rmdir() on ESP8266.
Although upysh.py bug fix

- rmdir = os.rmdir
+ rmdir = os.remove

works (on ESP8266), I'm not sure if it would be the correct solution for all platforms? (I therefore canceled #81).

pfalcon added a commit that referenced this pull request Jul 16, 2016
pfalcon added a commit that referenced this pull request Jul 16, 2016
@pfalcon
Copy link
Contributor

pfalcon commented Jul 16, 2016

os.rmdir() was implemented in esp8266 port. "clear" command was added, based on implementation in this patch. Thanks!

@pfalcon pfalcon closed this Jul 16, 2016
pfalcon added a commit to pfalcon/pycopy-lib that referenced this pull request May 3, 2020
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.

4 participants