-
Notifications
You must be signed in to change notification settings - Fork 109
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
add support for command line arguments to be passed on to python script (-py option) #19
base: master
Are you sure you want to change the base?
Conversation
all in all: looks like a good job. |
I'm gonna try to build on OSX. will report back |
Hello. @aoloe The reason I had to separate args and flags is simply because I did not want to presume too much about the syntax of the script arguments... and to handle the final (scribus) positional argument (filename) correctly: otherwise how do you know if Another option I see feasible is to have a single argument, that simply superseeds the standard command line arguments parsing mechanism and pass everything that follows to the script, not event parsing it.... seems quite clean to me, but maybe less conform to classical use, i.e. @luzpaz thanks for the test. |
@luzpaz https://travis-ci.org/scribusproject/scribus/jobs/74267458#L4384 is a warning in objprinter.cpp ... I changed no code in there. want me to have a look to try fix the warning? |
@berteh Thanks! But, better to keep the patch very concise. Lets not fix issue unrelated to what you are trying to achieve here. Better to submit a separate patch for a different fix. It's less auditing work for the devs. |
@berteh another thing. Can you give some instruction on how to test this ? |
FYI, it's cool that you can throw .diff or .patch at the end of a github url like https://github.com/scribusproject/scribus/pull/19.patch and it will generate a legit .patch. That's how I tested this patch via OSX: https://gist.github.com/luzpaz/69c00f2a8516b5462614#file-scribuspatch-rb-L41-L44 |
@luzpaz easiest way to test is, to me, to run a simple python script that prints any argument it gets (see below) and call if from command line via scribus save the script below as
running scribus with this patch via
would then output
and running it with an additional sla file (that needs to exist on your machine):
would generate the following output... proving the script has been running properly.
|
@berteh Excellent. The patch works!!
|
tldr; why should somebody care if the parameters are passed with one or two dashes? why can't we stick to the one dash fits all? and here are the details... :-)
personally, i prefer a clean, non-ambiguous and simple syntax (even with longer argument names, since you're not really supposed to type all of that, but rather put them in a script...) to complex ways to accommodate the wishes of every user... something like:
a long comment, ... and not much different than my previous one... sorry... but i think it's important to get the interface right... history has proven that later changes are hard to get into the trunk :-( |
@luzpaz < "when specifying an .sla the script will execute and then exit scribus. Is that what we want ?" yes if you specify -g option (as i guess you did). If not, scribus opens the sla, runs the script and does not exit. @luzpaz < forgo showing the splash screen when telling scribus to exectute python scripts from the CLI. +1, but I'd rather bind the no-splash to the "-g" (no-gui) option, and not to the script thing... but you can as well simply add @aoloe < --python-argi is imo less readable than --python-arg-i... agreed, and @aoloe < only long arguments (why not? ) ; why should somebody care if the parameters are passed with one or two dashes 1 or 2 dash is a mere convention. Usually in linux you have 1 dash for short argument form (typically single letter, like -d) and 2 dashes for synonym long form (like --debug)... it's standard in most Python arguments parsing librairies, like argparse and both are supported by the current patch, to the preference of the script author, for both arguments and flags, without any extra code... so I'd keep it that way, no need to enforce a single dash. @aoloe < once --python-run is set, the filename is ignored by scribus and must be opened by the script. would look much nicer from the command line, but requires more work in refactoring all scripts to work "from command line", as most currently are modifying the document already opened in scribus... which is directly supported if you "let" scribus open the last argument. @aoloe < i prefer a clean, non-ambiguous and simple syntax (even with longer argument names) agreed. then I'd not ignore the last (sla file) optional argument, as it would be ambiguous. about clean, how is the following not clean, to you? (so I know what to try to improve) what I like is you can directly see what goes to scribus and what goes to the script independently of their order on the command line. |
to me and i really would prefer:
i don't quite see why we should have scribus has a long history of "we do it because we can (and because somebody might want it)" and this makes the life harder for the users and for the programmers :-( add the features you can't keep out of the code base :-) |
@aoloe ok. if you prefer
the new Would that be better to you? |
the not specific for the scripter... i've already seen that in other tools, that's why i thought about it. (and no, i would not prefert to have all python args in one block :-) |
Ok. I'll try to do that... but it seems more difficult to explain (to me) than the flag/arg mechanism. |
in fact... I cannot come up with a simple sentence to explain it in the usage info. How would you explain it please? tried the following but it turns awful: |
i would say:
(not tested) the |
... hum that does not explain why you'd still be allowed to put the positional (file) argument behind |
i googled for it (and it was not easy to google for but it's not that far... i think that we should just document what the meaning of |
ok. thanks. learned something today ;) |
FYI Once we iron out all the details we need to submit patch to bugs.scribus.net (this is how the devs prefer). Github master is meant to only act as a mirror. |
…command-line double dash for options end
@berteh tomorrow i'll have some time and have a look at the code! thansk for your work (and your patience!) |
@luzpaz I was just procrastinating on this. now it's done. sorry for the delay. |
submitted at http://bugs.scribus.net/view.php?id=13311 |
@berteh 👍 |
nice! thanks @berteh for this patch! |
syntax of command line updated per Craig request:
|
@chhitz this PR was submitted to SVN and was accepted. We're trying to figure out a way to give the correct credit to folks submitting PRs that get committed via SVN instead of just closing the PR without attribution or success. One way is to commit and then revert the commit and then wait for the changes from SVN to get pushed to github. Can we add this function to svn-to-git script that you made ? CC @aoloe |
Sorry. pushed wrong button to comment. |
would be nice indeed. thanks for suggesting it. |
Looks like there is a regression...? |
was one indeed. fixed by Craig in 011680a, thanks! |
Craig closed ticket on BT http://bugs.scribus.net/view.php?id=13311 |
eh eh, no i said that we should check them and see if they allow us to accept a PR without touching the commits list... |
@berteh check out http://bugs.scribus.net/view.php?id=13408 |
@luzpaz got your ping, thanks! |
@berteh |
The painter state should be restored before drawing the fill. Fixes scribusproject#19.
The painter state should be restored before drawing the fill. Fixes scribusproject#19.
The painter state should be restored before drawing the fill. Fixes scribusproject#19.
adding 2 options to pass arguments to python script run in Scribus from command line (to be used with -py and -g), after short discussion with a-l-e on irc.