Skip to content

Commit

Permalink
Merge pull request #436 from tetious/dotnet-core-shell
Browse files Browse the repository at this point in the history
Add dotnet core support for shell
  • Loading branch information
mbdavid authored Jan 24, 2017
2 parents c99cf36 + ae1b874 commit eb94a2a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LiteDB.Shell/Commands/Collections/Bulk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void Execute(LiteEngine engine, StringScanner s, Display display, InputCo
var col = this.ReadCollection(engine, s);
var filename = s.Scan(@".*");

using (var sr = new StreamReader(filename, Encoding.UTF8))
using (var sr = new StreamReader(new FileStream(filename, System.IO.FileMode.Open)))
{
var docs = JsonSerializer.DeserializeArray(sr);

Expand Down
6 changes: 6 additions & 0 deletions LiteDB.Shell/Commands/Console/ShowCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public bool IsCommand(StringScanner s)

public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
{
if(engine == null)
{
display.WriteError("No database file currently open.");
return;
}

var cols = engine.GetCollectionNames().OrderBy(x => x).ToArray();

if (cols.Length > 0)
Expand Down
6 changes: 5 additions & 1 deletion LiteDB.Shell/Shell/Env.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ public LiteEngine CreateEngine(DataAccess access)
var disk = new FileDiskService(this.Filename,
new FileOptions
{
FileMode = FileMode.Shared,
#if NET35
FileMode = FileMode.Shared,
#else
FileMode = FileMode.Exclusive,
#endif
Journal = this.Journal
});

Expand Down
4 changes: 2 additions & 2 deletions LiteDB.Shell/Shell/ShellProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public static void Start(InputCommand input, Display display)
public static void RegisterCommands(List<ICommand> commands)
{
var type = typeof(ICommand);
var types = Assembly.GetExecutingAssembly()
var types = typeof(ShellProgram).GetTypeInfo().Assembly
.GetTypes()
.Where(p => type.IsAssignableFrom(p) && p.IsClass);
.Where(p => type.IsAssignableFrom(p) && p.GetTypeInfo().IsClass);

foreach(var cmd in types)
{
Expand Down
21 changes: 21 additions & 0 deletions LiteDB.Shell/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {
"LiteDB": "3.0.0"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"imports": "dnxcore50"
}
}
}

0 comments on commit eb94a2a

Please sign in to comment.