Skip to content

Commit d1fb2f6

Browse files
vkuttypclaude
andcommitted
release: 2.5.1 — cosmokv CLI accepts bare paths
`cosmokv ./mydb` is now sqlite3-style shorthand for `cosmokv 'DataSource=./mydb'`. The connection-string form still works and remains the way to set options like `CreateIfMissing=true`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ab7f0ee commit d1fb2f6

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<Authors>vkuttyp</Authors>
88
<PackageLicenseExpression>MIT</PackageLicenseExpression>
99
<RepositoryUrl>https://github.com/vkuttyp/CosmoSQLClient-Dotnet</RepositoryUrl>
10-
<Version>2.5.0</Version>
10+
<Version>2.5.1</Version>
1111
</PropertyGroup>
1212
</Project>

src/CosmoSQLClient.CosmoKv.Cli/Cli.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ private static void PrintUsage()
5656
cosmokv --help
5757
5858
ARGS
59-
<database> Path to a CosmoKv data directory, or a connection
60-
string like 'DataSource=./db;CreateIfMissing=true'.
59+
<database> Path to a CosmoKv data directory (e.g. ./db), or a
60+
connection string like
61+
'DataSource=./db;CreateIfMissing=true' when you need
62+
to set options.
6163
sql SQL to execute once; without it, drops into REPL.
6264
6365
OPTIONS
@@ -101,7 +103,7 @@ public static ParsedArgs Parse(string[] args)
101103
}
102104
positional.Add(a);
103105
}
104-
if (positional.Count >= 1) p.DataSource = positional[0];
106+
if (positional.Count >= 1) p.DataSource = NormalizeDataSource(positional[0]);
105107
if (positional.Count >= 2)
106108
{
107109
if (positional[1] == "-") p.ReadStdin = true;
@@ -110,6 +112,15 @@ public static ParsedArgs Parse(string[] args)
110112
return p;
111113
}
112114

115+
/// <summary>
116+
/// `cosmokv ./db` is sqlite3-style shorthand for
117+
/// `cosmokv 'DataSource=./db'`. If the user already passed a connection
118+
/// string (contains `=`), leave it alone. Empty string is rejected
119+
/// downstream by CosmoKvConfiguration.Parse.
120+
/// </summary>
121+
private static string NormalizeDataSource(string arg)
122+
=> arg.Contains('=') ? arg : "DataSource=" + arg;
123+
113124
public static OutputFormat ParseFormat(string s) => s.ToLowerInvariant() switch
114125
{
115126
"table" => OutputFormat.Table,

src/CosmoSQLClient.CosmoKv.Cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cosmokv [--format=FMT] <database> - # read SQL from stdin
1818
cosmokv --help
1919
```
2020

21-
`<database>` is either a directory path (e.g. `./mydb`) or a CosmoKv connection string (`DataSource=./mydb;CreateIfMissing=true`).
21+
`<database>` is either a bare directory path (e.g. `./mydb``sqlite3`-style) or a full connection string (`DataSource=./mydb;CreateIfMissing=true`). The bare form is shorthand for `DataSource=<path>`; use the connection-string form when you need to set options like `CreateIfMissing=true`.
2222

2323
### REPL
2424

0 commit comments

Comments
 (0)