Comments (14)
I think this is of higher priority, @jmsfltchr @lolski. This affects the user experience at the first point of entry. @vmax can you take this on?
from typedb-console.
My suspicion is that Windows have their own colour code characters.
from typedb-console.
@jmsfltchr @haikalpribadi @lolski I did a few tests on Windows and can confirm it's indeed an issue if you use CMD or PowerShell
However, there's a simple workaround that our users could do: use modern Windows Terminal!
To ease the pain of those who don't use it, I suggest we add an argument to Console binary named --nocolor
(or --color=no
), which, as name suggests, would skip printing the escape codes.
from typedb-console.
Can we detect the terminal at bootup of the console application and configure the colour options, @vmax ? Having to manually add the argument by the user feels clunky and not elegant.
from typedb-console.
@haikalpribadi @lolski I verified it's possible to know if we're running under Windows Terminal by checking WT_SESSION
presence of environment variable, ref. Therefore the heuristic for determining if we want to show colors would be:
if OS == Windows:
if environment variable WT_SESSION is present:
show colors
else
show colors
else:
show colors
from typedb-console.
Where should you implement this heuristic, @vmax ? Do you know how to implement it?
from typedb-console.
@haikalpribadi os detection would probably go into @graknlabs_common
; logic on enabling/disabling colors goes into Console. Yup, I'll implement this one.
from typedb-console.
I think it would be better if we can identify the OS in Java, and then configure the default colour setting also in Java, @vmax. I think that would be much cleaner. Is that possible?
from typedb-console.
@haikalpribadi all of the logic would be in Java, no doubt - it's just which Java package to put it one. Sorry I wasn't clear on this one; when I said @graknlabs_common
I in fact meant https://github.com/graknlabs/common/tree/master/util (not grakn
or grakn.bat
scripts)
from typedb-console.
Ah okay. Good. Let's do the logic in Java. Put the class in grakn.common.util.
. Use the library in Console to determine if it should output colour.
from typedb-console.
Detecting if a user's terminal supports colours is actually pretty involved. Here's one (NodeJS based) tool designed to perform such detection: https://github.com/chalk/supports-color
from typedb-console.
well, I think we can just detect the OS like how max suggests above, right, @alexjpwalker ?
from typedb-console.
It's not an OS-specific issue, but a terminal-specific one. The terminal I use most often when developing in Windows is the terminal built into Visual Studio Code, which does support colours - including on Windows.
So the most correct solution here is terminal detection, which - granted - is a little more involved than OS detection, @haikalpribadi
from typedb-console.
@haikalpribadi we went for a better and easier solution which just allows to print colors on Windows.
from typedb-console.
Related Issues (20)
- Print the concepts that are being deleted HOT 1
- TypeDB Cluster management HOT 2
- User role management
- Distribution JARs must be uniquely identified by their Maven coordinates HOT 1
- Log a warning if the current locale does not support all Unicode characters
- Allow multi-line query in Console scripts
- Connection error when querying TypeDB Cluster database schema HOT 1
- Defining concepts Type does not exist HOT 3
- 'source' commands on windows crash on exception
- "Missing credential" error is not user-friendly (connecting to TypeDB Cluster without correct args) HOT 1
- Support multiple layers of abstract commands
- Export schema in a file without unnecessary lines HOT 1
- Session not disconnected after a password change resulting in an Exception. HOT 1
- Confirm a password change before updating a user's password
- Wildcard support
- Greek characters/vaticle HOT 1
- Termination of commands and TypeQL queries is better to be consistent
- Respect default port when connecting by IP/domain name only
- Uncaught exception with Ctrl+C instead of input on password update
- Password-update command is redundant and behaves inconsistently to password-set HOT 1
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 typedb-console.