Skip to content

Commit 2ebac7e

Browse files
committed
small adjustments in syntax highlighting -> v0.1.0
1 parent afe77d6 commit 2ebac7e

File tree

8 files changed

+44
-15
lines changed

8 files changed

+44
-15
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,4 +353,5 @@ MigrationBackup/
353353
.idea
354354

355355
dump.rdb
356-
publish*
356+
publish-*
357+
*.zip

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<VersionPrefix>0.1.0</VersionPrefix>
4-
<VersionSuffix>snapshot</VersionSuffix>
4+
<!-- <VersionSuffix>snapshot</VersionSuffix>-->
55
</PropertyGroup>
66

77
<PropertyGroup>

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ let openSessionCount =
5252
select sessionKey
5353
|> count()
5454
where openSessionCount > 0
55-
let userJson = GET(userKey)
55+
let userJson = get(userKey)
5656
select (key: userKey, name: userJson[".name"]);
5757
```
5858
Response:
@@ -378,6 +378,8 @@ json["$.answer"];
378378
42
379379
```
380380

381+
Values extracted from JSON are translated to their corresponding RedisQL types, so a JSON integer values becomes a RedisQL integer, a JSON array becomes a RedisQL list etc.
382+
381383
## Bindings
382384
Bind values anytime in the REPL's top most scope using the `let` statement:
383385
```csharp

publish.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
VERSION=0.1.0
2+
3+
rm -Rf publish-*
4+
5+
# OSX
6+
dotnet publish src/RedisQ.Cli -r osx-x64 -o publish-osx -p:PublishTrimmed=true -c Release --self-contained
7+
mv publish-osx/RedisQ.Cli publish-osx/redis-q
8+
zip -r redis-q.$VERSION.osx-x64.zip publish-osx/*
9+
10+
# Linux
11+
dotnet publish src/RedisQ.Cli -r linux-x64 -o publish-linux -p:PublishTrimmed=true -c Release --self-contained
12+
mv publish-linux/RedisQ.Cli publish-linux/redis-q
13+
zip -r redis-q.$VERSION.linux-x64.zip publish-linux/*
14+
15+
# Windows
16+
dotnet publish src/RedisQ.Cli -r win-x64 -o publish-win -p:PublishTrimmed=true -c Release --self-contained
17+
mv publish-win/RedisQ.Cli.exe publish-win/redis-q.exe
18+
zip -r redis-q.$VERSION.win-x64.zip publish-win/*

src/RedisQ.Cli/IRepl.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,23 @@ internal class PrettyRepl : IRepl
4545
public PrettyRepl(char terminator, Compiler compiler)
4646
{
4747
var promptStr = new FormattedString("> ", new FormatSpan(0, 2, AnsiColor.BrightBlack));
48+
var historyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".redis-q-history");
4849
_prompt = new Prompt(
4950
configuration: new PromptConfiguration(prompt: promptStr),
50-
callbacks: new LocalPromptCallbacks(compiler, terminator));
51+
callbacks: new LocalPromptCallbacks(compiler, terminator),
52+
persistentHistoryFilepath: historyPath);
5153
}
5254

5355
public async Task<string> ReadSource()
5456
{
55-
var response = await _prompt.ReadLineAsync();
56-
return response.IsSuccess
57-
? response.Text
58-
: string.Empty;
57+
var response = await _prompt.ReadLineAsync().ConfigureAwait(false);
58+
if (!response.IsSuccess) return string.Empty;
59+
if (response is KeyPressCallbackResult callbackOutput)
60+
{
61+
Console.WriteLine(Environment.NewLine + callbackOutput.Output);
62+
return string.Empty;
63+
}
64+
return response.Text;
5965
}
6066

6167
private class LocalPromptCallbacks : PromptCallbacks
@@ -122,7 +128,7 @@ protected override Task<KeyPress> TransformKeyPressAsync(string text, int caret,
122128

123129
protected override Task<IReadOnlyCollection<FormatSpan>> HighlightCallbackAsync(string text, CancellationToken cancellationToken)
124130
{
125-
if (text.StartsWith("#")) return Task.FromResult(new[] { new FormatSpan(0, text.Length, AnsiColor.Green) } as IReadOnlyCollection<FormatSpan>);
131+
if (text.StartsWith("#")) return Task.FromResult(new[] { new FormatSpan(0, text.Length, AnsiColor.Magenta) } as IReadOnlyCollection<FormatSpan>);
126132
var tokens = _compiler.Lex(text);
127133
var spans = tokens
128134
.Where(token => token.StartIndex >= 0 && token.StopIndex >= token.StartIndex)
@@ -133,13 +139,12 @@ protected override Task<IReadOnlyCollection<FormatSpan>> HighlightCallbackAsync(
133139
Length = token.StopIndex - token.StartIndex + 1,
134140
}).Select(t => t switch
135141
{
136-
_ when Keywords.Contains(t.Type) => new FormatSpan(t.StartIndex, t.Length, AnsiColor.BrightMagenta),
137-
_ when Operators.Contains(t.Type) => new FormatSpan(t.StartIndex, t.Length, AnsiColor.BrightMagenta),
142+
_ when Keywords.Contains(t.Type) => new FormatSpan(t.StartIndex, t.Length, AnsiColor.BrightCyan),
143+
//_ when Operators.Contains(t.Type) => new FormatSpan(t.StartIndex, t.Length, AnsiColor.BrightCyan),
138144
_ => t.Type switch
139145
{
140-
Tokens.Comment => new FormatSpan(t.StartIndex, t.Length, AnsiColor.Green),
141146
Tokens.Integer or RedisQLLexer.Real => new FormatSpan(t.StartIndex, t.Length, AnsiColor.BrightYellow),
142-
Tokens.SingleQuotedString or RedisQLLexer.DoubleQuotedString => new FormatSpan(t.StartIndex, t.Length, AnsiColor.BrightCyan),
147+
Tokens.SingleQuotedString or RedisQLLexer.DoubleQuotedString => new FormatSpan(t.StartIndex, t.Length, AnsiColor.BrightGreen),
143148
_ => new FormatSpan(t.StartIndex, t.Length, AnsiColor.BrightWhite),
144149
},
145150
});

src/RedisQ.Cli/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ private static void PrintBanner(Options options)
5050
Console.WriteLine($"***** redis-q v{version}");
5151
Console.WriteLine($"redis @ {options.ConnectionString}");
5252
Console.WriteLine("terminate expressions with ;");
53-
Console.WriteLine("enter #q; to exit...");
53+
Console.WriteLine("enter #q; to quit...");
54+
Console.WriteLine();
5455
}
5556

5657
private static async Task<Value?> Interpret(Compiler compiler, string source, Context ctx, Options options)

src/RedisQ.Cli/ValuePrinter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ private async Task PrintEnumerable(IAsyncEnumerable<Value> values, TextWriter wr
5555
{
5656
await Print(v, writer, indent + " ");
5757
}
58+
await writer.WriteLineAsync();
5859
}
5960
}
6061
catch (RuntimeException e)

src/RedisQ.Core/RedisQ.Core.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
disabled warnings (produced by antlr generated source):
99
CS2002 source file specified multiple times;
1010
CS3021 ClsCompliant class in assembly that is not ClsCompliant;
11+
NU1605 package downgrade produced by netstandard 1.3 references (ANTLR)
1112
-->
12-
<NoWarn>CS2002;CS3021</NoWarn>
13+
<NoWarn>CS2002;CS3021;NU1605</NoWarn>
1314
</PropertyGroup>
1415

1516
<ItemGroup>

0 commit comments

Comments
 (0)