Comments (10)
@dufferzafar, just to be sure, did you solve your issue? I didn't try but I guess it can be sorted out by quoting the executable path. Did you try this?
It's true that the current way it's working could be improved. Perhaps massren could detect the ".exe" part in Windows and, if found, quote the path automatically.
from massren.
I did solve the issue, by moving my Sublime text to: F:\Sublime\subl.exe
LIKE A BOSS 😄
from massren.
Still not fixed.
What do we do to handle flags. Mostly flags start with either dashes or slahes and will have a space preceding them.
C:\Program Files\VSCode.exe -g -x
or C:\Program Files\VSCode.exe /g /x
should be handled.
Can we split only when we find both a space and a - or / or --?
from massren.
This works but removes the leading -, --, and /.
pieces := make([]string,0)
if (strings.Contains(editorCmd, "--")) {
pieces = strings.Split(editorCmd, " --")
} else if (strings.Contains(editorCmd, " -")) {
pieces = strings.Split(editorCmd, " -")
} else if (strings.Split(editorCmd, " /") {
pieces = strings.Split(editorCmd, " /")
} else {
pieces = strings.Split(editorCmd, " ")
}
pieces = append(pieces, "file1.txt")
This turns C:/Program Files/VSCode.exe -f -g
and a file.txt to C:/Program Files/VSCode.exe f g file.txt
.
Also it seems we cannot mix and match two kinds of flags at once (like vscode.exe --newwindow -f)
from massren.
Hmm, yes that seems quite complex because it indeed looks like we should parse the flags if we want to support this properly.
Ideally, I think the test cases we should be able to handle are:
subl
/usr/bin/vim -f
"F:\Sublime Text 3\sublime_text.exe" -n -w
subl -w --command "something with spaces"
notepad /PT
Case that we do not need to handle:
F:\Sublime Text 3\sublime_text.exe -n -w
Because this is not a valid command since there should be quotes around the executable path and name.
Maybe a simple solution would to use a dedicated flag parser like go-flags?
from massren.
Go-flag looks well suited, we can even parse from strings.
from massren.
I'll add those testcases to a separate test file for now so that they don't hinder with the Travis CI builds.
from massren.
I got this going now. The code is working locally on the testcases. I dont have internet right now (on my mobile currently). I'll get it through Travis and submit a PR once i get hold of internet.
from massren.
Thanks, I've moved the parsing code to a function so that we can unit test it, and added the unit tests for it in Test_parseEditorCommand
. At the moment, some of the tests are failing due to quote and space issues. Basically, the tests check that the function returns the executable path and the arguments. For example, they expect this:
"/usr/bin/vim -v -i"
is going to be parsed into:
executable: /usr/bin/vim
args (a slice): [ -v, -i ]
and:
subl -w --command "something with spaces"
into:
executable: subl
args: [ -w, --command, something with spaces ]
Maybe I didn't refactor your code correctly though, please have a look just to make sure. The command to run the tests is go test
.
from massren.
I'll check it out by Saturday. Thanks for the refactoring.
Although I think we both have different ideas of how we would like to implement it.
The way I had written the code will never allow the second case you mentioned to pass. It always expects quotes when there are spaces.
But i think what you are aiming for is better. I'll try and implement that too.
from massren.
Related Issues (20)
- -n and -v give very similar (read: the same) output HOT 2
- Freezes when no changes are made HOT 6
- Monitor text editor process ID and close massren if it's gone HOT 1
- Feature request: Option to merge directories upon name conflict rather than throwing an error HOT 2
- Cannot lowercase names HOT 2
- Dealing with already existing destination HOT 3
- Submit to Homebrew official repository HOT 10
- ENHANCEMENT As a user I want (the option) to ignore file extensions so I don't have to create regex
- `include_header` is not removing header HOT 2
- Research recursive file naming #Help #Question HOT 4
- Review/fix file name punctuation (i.e. question mark ?) breaking output list order #Bug
- Option to disable the giant message every time I do a renaming operation. HOT 2
- support go modules for go 1.16 or brew will soon stop being able to build massren
- Support auto filename validation HOT 1
- Handle newlines in filenames
- Temporarily override the set editor?
- Is this project abandoned? HOT 3
- 👋 Newly windows user here :)
- `massren .` HOT 3
- Order of filenames is not respect to explorer HOT 2
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 massren.