Comments (11)
You can further simplify @noyoshi's code:
cmd, *args = cmd.split()
Requires Python 3.
from terminusbrowser.
I think a better way of handling routeCommand
would be doing something like
cmdList = cmd.split()
cmd = cmdList[0]
args = cmdList[1:]
then passing in cmd and args to the functions systemCommands
, chanCommands
, etc.
I think using split here is fine, because we want each thing in the list. But we should be doing checks to make sure we have the appropriate number of args each function is expecting to prevent the error.
from terminusbrowser.
I might be wrong, but I think for point 3 the .site might be deprecated. We recently changed the structure and I think that it has very little use anymore.
from terminusbrowser.
I was actually planning on wrapping up the command handlers with pytest tests, before implementing the new cmd,args[] discussed above.
As part of testing, I will add cmd & args size checks, per module requirements.
Would you like me to make a new ticket for the tests @wtheisen?
I will tag the size checks for commands to this, as it directly solves the ticket.
And maybe a different one for the cmd/arg change, as it's an ideological change, more than anything?
I would appreciate a sanity check on the above proposed :)
from terminusbrowser.
I think it's fine to wrap it all as one big change, and all of those sound very helpful and useful! I think what @pbui posted earlier also makes a lot of sense to use. Full steam ahead I'd say these are all very good ideas!
from terminusbrowser.
Hey Chavdar, looking at this now.
Feeding b or t causes the program to crash because those are shorthand for commands board and thread. We haven't added in a check to src/Commands/ChanCommands.py
to ensure that the full command has been entered (which is why the error is an index error when only one arg, b or t, is passed). So if just b is entered as a command, it will attempt to run board(uvm, cmd[1])
, but cmd[1] does not exist. This needs to be fixed, good catch.
Per your bullet points:
-
Agreed that the command should be lowercase'd, probably in the
routeCommand
function ofsrc/commandHandlerClass.py
. -
I'm not so sure on I follow how this one affects what we have in place currently. Could you maybe give an example of a command being handled in this way? I think it'd also be good to hear from @wtheisen and @sambattalio on this one if it changes the way we are handling commands. If it's more so a syntactical change, and not a large structure change, I'm for it.
-
It looks like we don't do a very consistent job of setting the site attribute for a given view, which would explain why it is returning
None
when you attempt to debug for it. I just did a quick check of this:
I added self.uvm.currFocusView.site = SITE.HACKERNEWS
to the __init__
method of src/Frames/hackernews/indexFrame.py
.
Then, I added log.warning(self.uvm.currFocusView.site)
to routeCommand
, and navigated to an HN thread. When I checked the log : [ WARNING]:commandHandlerClass.py #32 --- SITE.HACKERNEWS
Again, good catch, this is something that needs to be fixed :)
from terminusbrowser.
Thank you @ginglis13, I didn't realize what cmd's payload was meant to be. Things make more sense now!
@sambattalio In another issue, there was talks if possibly keeping .site, hence why I wanted to use it... but seems like the idea is to be able to run all commands from anywhere?
In any case,@noyoshi 's approach is seriously beautiful and simply handles the currently existing problem, without limiting any functionality, so I'll go with it for now!
from terminusbrowser.
Thank you for the swift and very detailed response!
The ticket isn't very focused... as you can tell.Thing is, the false t/b cmd handling feels like a symptom of a bigger issue, that I'd like to nip once and not worry about in the future.
About point 2: I was trying to understand the reason behind using split, rather than an array itterator.. as it seems like it can be a can of worms. Haven't tested any possible issues yet, but it feels like a non-pythonical way of approaching that.
About point 3: Shall I take it this will be fixed soon? If not, I can add them as well. Probably a different issue/commit should be made though.
from terminusbrowser.
@Sipty the command is passed in as a string, captured from the edit text of the command bar. If one were to iterate over the command using for c in cmd:
, c
will represent an individual character in the command, not a word, which I believe is the reason for using .split()
in this case. Is this a correct interpretation of your suggestion?
edit: here's a log output. All warnings referencing line 31 of commandHandlerClass.py
show that the 'command' is a string containing the command and its argument(s)
from terminusbrowser.
So the reason t and b crash by themselves is they try to run the thread and board command with an incomplete list of arguments. I think we're going to have to use split() regardless due to the way the data is set up. However in order to fix these crashes, and ones similar, we just need to add more complete error checking to the individual commands themselves. This should happen in the different site command files I think. Nice catch on the bug though I had forgot to check for these things. Maybe @ginglis13 can write some more tests to check the commands? Add a command success boolean we can check after a command is run. This helps testing and also would allow us to provide feedback to the user as the the validity of their command.
from terminusbrowser.
Adding to list:
the command 'history reddit' crashes the program as well
from terminusbrowser.
Related Issues (20)
- Generalizing frame visual structure HOT 1
- Name change HOT 4
- Make history frame look better
- Coloring Relevant Information HOT 3
- Lainchan board improvements. HOT 3
- Mouse click causes crash
- test of webhook HOT 5
- Update Name Instances HOT 4
- Tests Badge Not Displaying Properly HOT 2
- Hackernews - Loading Stories
- Feat: Update Reddit to PRAW HOT 4
- Option for subreddit and 4chan page removal HOT 1
- Feat Request: Settings View HOT 1
- Can't quit program using source file HOT 3
- Feature Request: debug.log refresh on new instance
- cannot run browser on python 3.5.3 -- update docs HOT 1
- Conformity to PEP8 File Naming Conventions
- Command Collision Error Checking/Site specific ordering HOT 2
- I want to use this at school but I can't in install PIP
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terminusbrowser.