Closed kaislahattu closed 4 years ago
Version 3.9.1 is very old. Can you try to use our latest nightly build (https://nightlies.sqlitebrowser.org/latest/) or version 3.10.0 (currently in beta testing) from the releases section (https://github.com/sqlitebrowser/sqlitebrowser/releases) and see if the issue is fixed with any of them.
3.10.0 beta1 win64 DOES open the specified datafile, which addresses the main concern (for me). However, '--help' still does nothing, although some kind of a window flashes really quick before disappearing. '-s' seem to open the application just as if it were started normally without commanline options (does not complain about missing SQL or such...).
To me it seems as if the Windows commandline options are still not working entirely as intended - but that the databasefile can now be added into a shortcut is a major convenience for me - I'll be using this version from now on.
Ahhh, are you running the commands from a batch file, or from the command line?
Asking because the --help
option is pretty much targeted at people running it from the command line. In theory if you run it from there, it should display the list of known command line options and what they're for.
If it's not doing that for you though, then it's probably a bug. :wink:
I have a command prompt open and I am typing these ..."tests" in there (not using a batch file). I'm a happy camper now regardless - I can have my shortcuts for each datafile :)
Cool. :smile:
Question: Since this ticket mentions an old version, should this be closed and new created for new version (in which '--help' does not produce expected command prompt output)? ...or can this be updated? (my github fluency is remarkably non-existent)
In theory, you should be able to edit the comments and issues you've created. On the top right of any of the comments, and the original description, there should be a clickable little pencil icon which makes it go into edit mode. Give that a shot. :smile:
As a reference data point, this is what --help
shows on the command line for me on OSX with our very latest source code:
$ src/DB\ Browser\ for\ SQLite.app/Contents/MacOS/DB\ Browser\ for\ SQLite --help
Usage: src/DB Browser for SQLite.app/Contents/MacOS/DB Browser for SQLite [options] [db]
Possible command line arguments:
-h, --help Show command line options
-q, --quit Exit application after running scripts
-s, --sql [file] Execute this SQL file after opening the DB
-t, --table [table] Browse this table after opening the DB
-v, --version Display the current version
[file] Open this SQLite database
The long name needed to launch the app is just a side effect of how it's compiled on OSX. On Linux it should still be sqlitebrowser
, so is easier to launch. :wink:
My Windows prompt looks like this:
C:\Program Files\DB Browser for SQLite>"DB Browser for SQLite.exe" -v
C:\Program Files\DB Browser for SQLite>"DB Browser for SQLite.exe" --help
C:\Program Files\DB Browser for SQLite>"DB Browser for SQLite.exe" --please_say_something
C:\Program Files\DB Browser for SQLite>
Interesting. I'll try it out on a Windows VM in a bit, and see if the same thing happens to me (eg verify the problem).
It's possible our code to output the options is being skipped on Windows for some reason.
Also note that if you do put gibberish, DB4S doesn't moan. So db browser for sqlite.exe "mary had a little lamb.db"
only opens a 'clean' DB4S window - it doesn't report that that file doesn't exist, or the command option was invalid.
Specifiying a valid filename does work.
This is kinda linked to the other issue when Martin added debug code to DB4S but the Windows version wasn't outputting it. Its as if DB4S is trying to display text to the console, but there is no 'console' to output it to.
This kind of makes sense, as the command prompt fires off DB4S and then hands control back to the user. It doesn't keep a 'connection' open for output to be displayed back. Maybe 'if operating_system = "windows" then display_messagebox else display_to_console...'
Just tried this out on the Windows build VM, with our latest nightly build.
@kaislahattu is definitely correct. No options get printed out, and a light coloured application window (main DB4S window maybe?) is displayed on the screen for a fraction of a second. Not enough to recognise what it was, though maybe screencasting software would be able to grab a good look at it (can't be bothered atm though). :wink:
@chrisjlocke Yeah, it could be something like that. We're using qWarning()
to display stuff to the console... maybe it needs special treatment to get things showing correctly on Windows. :smile:
@kaislahattu I've just added 3.10.0-beta1
to our project issue template, to make things slightly easier for future issue reporters too. :smile:
though maybe screencasting software would be able to grab a good look at it
Or recording it on a smartphone? Just something we've done sometimes... (especially on BIOS errors at boot up .... crap, was it F9 for boot menu, or F12, or delete...)
and a light coloured application window (main DB4S window maybe?) is displayed on the screen for a fraction of a second.
If I run DB4S at a command prompt with the -h or --help options, DB4S just starts as normal.
Just did a screen recording (25 fps) on Windows 8.1 with the latest nightly. When calling "DB Browser for SQLite.exe" --help
, I soon can insert the next command into the command line window. 13 frames later a black window is shown which gets replaced with a white one in the next frame. This white window fades out afterwards (taking 4 frames). Comparing it with the size the DB4S window has when starting without options this seems to be the DB4S which is shown for the short period.
It's probably because of this: https://stackoverflow.com/questions/3360548/console-output-in-a-qt-gui-app. It doesn't sound like it's possible to have console output in a GUI application without any downsides. But there are some solutions suggested - if somebody with a Windows system wants to try them it would be interesting to know if any of them works. If so, feel free to open a PR, or just post it here and I'll make it platform-independent and commit it :smile:
For each solution, someone seems to moan that it doesn't work with X, Y or Z. Would it be easier to just use messageboxes? This is how Windows apps work.
Was trying to find a better example - thought excel, etc, used messageboxes for command line examples (ie, -?)
The commandline -v could then just bring up the standard 'about' box.
Yeah, that shouldn't be too hard.
Instead of using multiple qWarning()
calls to display the line, each of those lines could simple be used to construct a text message for display:
outputText = "-f, -foo some text here"
outputText += "-b, -bar some more text here"
[etc]
Then when the message is fully constructed, choose how to display it based upon the running platform. eg if it's Windows use a messagebox, otherwise use qWarning()
.
Blimey, that sounds so simple, even I could do it. ;) 🐒 I'll have to dig out my Windows VM with VS on it to have a go. 💩
I was thinking exactly the same as @chrisjlocke. Microsoft seems to be doing the same with a lot of apps, like Windows/MSI Installer.
DB4S should check if there is a command line before starting. If it is -v
or --version
it should display the About dialog window and maybe exit after that. If it is -h
or --help
, or if the commands are unknown, it should display something like the above screenshot and exit. If no commands are given it should start normal.
I don't think you need to do that - the 'processing' of the command line works, just not the displaying of messages. It should be easy to just exit (which wouldn't display the main form) if the -v or -h options are supplied.
Just to chime in:
Running (on Windows (Win7 Ultimate X64 and DB4S 3.10.0beta))
"DB Browser for SQLite.exe" DBNAME
from commandline opens the database.
But defining a file-association for extension .sqlite
does not work. Within Registry I have defined the key \\\Registry\HKEY_CLASSES_ROOT\Applications\DB Browser for SQLite.exe\shell\open\command\
with the value "D:\Usr\programs\DB Browser for SQLite\DB Browser for SQLite.exe" "%1"
and associated the file-extension sqlite
with Applications\DB Browser for SQLite.exe
.
Double clicking on file test.sqlite
opens DB Browser for SQLite.exe
- but the database is not loaded - the program is started with NO database loaded.
I didn't create the registry entries manually - rather than using standard window tools to create a fiel association.
@hoppfrosch Ouch, that sounds frustrating. Those steps seem like they should work.
Looking over the wiki page we have about Windows File Association bits, I'm not seeing anything in there different:
https://github.com/sqlitebrowser/sqlitebrowser/wiki/Windows-File-Associations
It's possible we've introduced some bug recently, though @chrisjlocke or @karim might have ideas for how to check what's going on. :smile:
One thought pops into my mind... you're familiar with creating batch files or powershell scripts, you could make something which logs it's command line parameters to a file. And then call that instead of "DB Browser for SQLite.exe" "%1"
, as a temporary way of verifying the file association thing is correctly passing the path to the database. The behaviour kind of sounds like something is going wrong with that bit somehow.
No idea if that's helpful though. :smile:
File associations are a pain. They shouldn't be, but the 'links' in the registry are just a mess and unclear. It 'used' to work with Win98 and XP, but it just got overly complicated in Win 7 and beyond.
I just created a .sqlite file, which Win 10 didn't know what to do with. "Associate it with that .exe there". "OK - done that", Windows replied. Nope, it used a completely different version of DB4S. Argh.
I'd recommend Nirsoft FileTypesMan. http://www.nirsoft.net/utils/file_types_manager.html
A free utility written by someone who knows what they're doing, rather than the 'interfaces' in Windows. So crazy. There are command line utils in Windows, but even they don't always work as required, especially if you have associations already - it seems to create entries, rather than modify them.
So here is my 'broken' association Win 10 just created...
(yup, I appreciate you're on Win 7... that utility will work on that too)
Full editing:
Which now works. Yay!
There is also a dialog which explains/allows you to edit the 'user choice' used on Vista/Win7 (and I presume 8 and 10)
Just tested file association on Windows 7 SP1 64-bit and it is working as intended.
If running "DB Browser for SQLite.exe" "path\to\db.sqlite"
from the commandline opens the database for you then there is nothing wrong with DB4S. Windows handles file association and it should pass the database file to DB4S so it can open it. Apparently, it is not doing so.
Something could be wrong with the registry. Can you try to reassign .sqlite extension to DB4S again? Press and hold Shift while right-clicking a database file and select Open with then Choose default program... and select DB4S again.
@chrisjlocke Ahhh, that's a nifty looking utility. Should we add that to our wiki page about file associations? :smile:
I can update that, yes. Its handy, for .db or .sqlite files as you can have your standard 'open' and also 'open in Beta', etc. Using this utility makes that easier.
@kaislahattu, after some time we have finally been able to solve this issue. Starting from tomorrow's nightly build, the messages related to command line arguments will be displayed in a message box. If you are still around, could you confirm it's working as expected?
@kaislahattu, after some time we have finally been able to solve this issue. Starting from tomorrow's nightly build, the messages related to command line arguments will be displayed in a message box. If you are still around, could you confirm it's working as expected?
Downloaded 24.08.2020 (v.3.12.99) .MSI and installed it. Program starts up with an message about missing "slot", but this is probably known and tracked elsewhere.
As for the help ("-h"), is there an inconsistency in argument naming? ([db] == [file] ?) I imagine it should be "[db]" in the end since [file] is already used by "-s" option.
I apologize for being a critic, but is "This is..." really necessary in the version dialog?
But as for testing if it now works - it does! Excellent!
Good stuff @kaislahattu, those are all good points. :smile:
I've just push a commit with those last two changes (153e02901a5ad0584f13047a7072fe48835838f8), so they should also appear in tomorrows nightly build as well.
I just noticed (from the commit) that there is some formatting (whitespace indent, \t tabs). Would it look horrendous if the -h output would be rendered in courier font? Could it render tabs also as intended?
This is cosmetic, of course. Information is now visible and that is the main thing, obviously.
Yes, I noticed it looked bad in a dialog (didn't realise it was tab-separated when I suggested it!). As its a system dialog, I don't believe it can be formatted - although the code does mention 'msgBox.setTextFormat(Qt::RichText);', so it might be able to be formatted...
Hmmm, we might be able to specify a monospace font?
@chrisjlocke - specify a setting in a qss (qt stylesheet) file. Easier to fight with CSS in text than to recompile/retest every little change/tweak. e.g.
DlgMsgBox {
text-align: center;
font-style: normal;
font-weight: normal;
font-size: 12pt;
font-family: "Courier, Monospace";
}
I'm currently running into this a few places in a PySide2 app I'm working on. Just plain easier to deal with CSS than make every single pendantic change like
wdgt_obj->setAlignment(Qt::AlignCenter);
wdgt_obj->setFont(QFont(...));
...
Qt Docs - Stylesheets (reference w/ links to APIs et al)
I've set the text in the dialog as preformatted rich text format. That will keep tabs and display in a monospace font. It will be available in the next nightly build.
I've set the text in the dialog as preformatted rich text format. That will keep tabs and display in a monospace font. It will be available in the next nightly build.
Looks good!
For anyone with a standard installation path, not an issue, but perhaps...
--- a/src/Application.cpp
+++ b/src/Application.cpp
@@ -88,7 +88,7 @@ Application::Application(int& argc, char** argv) :
if(arguments().at(i) == "-h" || arguments().at(i) == "--help")
{
// Help
- qWarning() << qPrintable(tr("Usage: %1 [options] [database]\n").arg(argv[0]));
+ qWarning() << qPrintable(tr("Usage: %1 [options] [database]\n").arg(basename(argv[0])));
qWarning() << qPrintable(tr("Possible command line arguments:"));
qWarning() << qPrintable(tr(" -h, --help\t\tShow command line options"));
qWarning() << qPrintable(tr(" -q, --quit\t\tExit application after running scripts"));
...and #include <libgen.h>
somewhere where it is appropriate?
But I really do mean that it really does look good now! Thank you everyone who were working on this!
EDIT Nevermind... that was Linux / POSIX call... :-)
Yes, I noticed the help contained the path too ... would be handy sans path, which seems the 'norm' in other applications?
Also, I assume the tab positions are OS dependant - whats right on one OS isn't right on another. It would be crazy having multiple texts for each OS ... quite unmanageable.... At least its only help text, so a minor issue.
@chrisjlocke
Yes, I noticed the help contained the path too ... would be handy sans path, which seems the 'norm' in other applications?
Is the path shown when you run it from the PATH or from inside the directory? What I observe in Linux is that argv[0] is exactly as invoked by the user. And some standard programs have the same behaviour in their usage output (e.g. ls) but others not (e.g. gcc). So not sure if it should repeat what the user has entered or not.
Also, I assume the tab positions are OS dependant - whats right on one OS isn't right on another. It would be crazy having multiple texts for each OS ... quite unmanageable.... At least its only help text, so a minor issue.
Yes, it looks better in Linux. There's no easy way to make them OS dependant, so I will favour Linux, which has more command-line users.
EDIT: But I see that some programs are using spaces, so maybe I change that.
@Jasata
EDIT Nevermind... that was Linux / POSIX call... :-)
Don't worry, it can be done portably with Qt, but I'd like to know if the path is also included when you run it without the path in the command.
Is the path shown when you run it from the PATH or from inside the directory?
No, I don't think so... if your DB Browser installation directory is in PATH, which for most users, I don't think it is. (Or in other words, if you manage to run the binary without the path to it, it is not automatically expanded/added to argv[0]). I believe that in order to be able to invoke the binary in a standard installation (with options - note the terminology in the help text; options vs arguments), you need to give the entire path and executable... and then the argv[0] has the path as in my examples.
I don't think the path is necessary though. For one, it won't add any information that the person who managed to get the help displayed, wouldn't already know (such as, where the binary is or how to successfully run it in command line). And strictly speaking its not even correct - you cannot copy paste that due to white space (if you could copy-paste it). From my point of view, its an "artifact" that doesn't really belong to similar helps, just as @chrisjlocke 's example shows.
But honestly, all this is now almost in the realm of nit picking. The fact that -v or -h are no longer silently consumed without feedback to users is the significant part - and it's OK now, as far as I see it. And for a cherry on top, its in monospaced font too! At least I am very happy with this as-is, invocation path showing or not.
So not sure if it should repeat what the user has entered or not.
As @Jasata points out, if you're running DB4S and invoking the -h option, I see no benefit of also showing the path, as you're more than likely there anyway. Just a personal thought. But yes, the fact its working at all, and in a monospace font is nice.
Thanks for the suggestions. I've made these improvements:
<placeholder> [optional]
See https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_01
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/command-line-syntax-keyHas someone taken a look into this? Is everything already addressed?
Has someone taken a look into this? Is everything already addressed?
Just DL'ed 31.08. nightly build (64-bit Windows) and ran it.
Some options seem to have been removed? -o
and -R
? Hate to nitpick, but how will a new user now understand that the database file can be supplied as an argument?
Oops, something went wrong with the rich text format. I'll fix it.
It should be fixed in next nightly build. Sorry, I didn't take enough attention to the last change :smile:
Can confirm works well! 👍
Looks good. :smile:
Works well and looks good doing it. -v
dialog seems to also have been added with a little bit new information, which is always nice.
Thank you again for everyone giving this issue time and fixing it. 👍
DB Browser for SQLite.exe I want the code for exporting csv and importing it to a database
Ideally, you should raise a new issue, as your issue is nothing to do with commandline options not working. Also, you need to explain what you are exporting the csv from .. how can anyone explain how to export a csv if you haven't explained what program you're using? Excel? Another database? Wind Farm Simulator 3?
Details for the issue
Version: 3.10.0 Beta1 OS: Win10 Home 1703
Application binary does not seem react to commandline options (using command prompt) in "expected" ways. For example, invoking the application with "--help" does not yield the expected help (as seen in the Application.cpp) into the command prompt. Issuing '-s' option without SQL does not seem to complain about the missing SQL (application merely starts normally).
Currently (today) I am unable to test Linux version for same behaviour.
Useful extra information
I'm opening this issue because:
I'm using DB4S on:
I'm using DB4S version:
I have also: