Skip to content
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

Some simplifying changes #3

Merged
merged 1 commit into from Nov 8, 2018
Merged

Some simplifying changes #3

merged 1 commit into from Nov 8, 2018

Conversation

ghost
Copy link

@ghost ghost commented Nov 8, 2018

Just made some simple changes to make the program look a bit prettier ;)

(btw, / is from ospaths module, which is exported by os, and allows to create paths using a more "natural" way).
Also, I didn't understand why you made path in crap procedure a var string instead of just string.

var del = ""
if paramCount() == 0:
echo("error: specify at least one file")
quit(1)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also changed quit(0) to quit(1) because that's more logical - if an error happens there shouldn't be a successfull exit code.

except OSError:
echo("error: no such file or directory")
quit(0)
echo("error: no such file or directory: " & del)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also added path to the file to the error which may help the user in case when moving fails

else:
trashHome = joinPath(getHomeDir(), ".local/share/Trash")
getHomeDir() / ".local/share/Trash"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be also changed to

getHomeDir() / ".local" / "share" / "Trash"

btw, but I don't think that it's really needed :D


let
t = getTime()
formattedTime = t.format("yyyy-MM-dd") & "T" & t.format("HH:MM:ss")
formattedTime = t.format("yyyy-MM-dd'T'HH:MM:ss")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is documented in official docs for the times module if you're wondering:

Other strings can be inserted by putting them in ''. 

@icyphox
Copy link
Owner

icyphox commented Nov 8, 2018

Hey,

That's wonderful! Thanks for these changes, and especially, for explaining each one. Real nice for someone still learning the language. And with regard to why path is a var string and not just a string, it's because I need it to be mutable for this action here:

path = extractFilename(fullPath)

Let me know if there's a better way to go about it. Thanks again :)

@icyphox icyphox merged commit fe2dedc into icyphox:master Nov 8, 2018
@ghost
Copy link
Author

ghost commented Nov 8, 2018

@icyphox ah, ok!
I actually changed this assignment of the path variable to the creation of the fname variable because it better represents that this variable actually holds file name (hence fname).

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.

1 participant