Skip to content

Commit

Permalink
Add info to readme re jumpstat -scan.
Browse files Browse the repository at this point in the history
Add support to read config data from Jump.Location.dll.config.
Minor cleanup.
  • Loading branch information
chinhdo committed Sep 21, 2014
1 parent 36922f0 commit 349cdae
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Jump.Location/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/></startup>
<appSettings>
<add key="Jump.Location.Scan.MaxSubFolders" value="50"/>
</appSettings>
</configuration>
7 changes: 7 additions & 0 deletions Jump.Location/CommandController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;

namespace Jump.Location
Expand All @@ -18,6 +20,11 @@ class CommandController

internal CommandController(IDatabase database, IFileStoreProvider fileStore)
{
// This is so that we can read config settings from DLL config file
string configFile = Assembly.GetExecutingAssembly().Location + ".config";
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", configFile);
ConfigurationManager.RefreshSection("appSettings");

this.database = database;
this.fileStore = fileStore;
var thread = new Thread(SaveLoop);
Expand Down
6 changes: 3 additions & 3 deletions Jump.Location/GetJumpStatusCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Jump.Location
using System;
using System.Configuration;
using System.IO;
using System.Reflection;

[Cmdlet("Get", "JumpStatus", DefaultParameterSetName = "Query")]
public class GetJumpStatusCommand : PSCmdlet
Expand Down Expand Up @@ -109,7 +110,6 @@ private void DoScan()

private void GetChildFolders(string dir, Dictionary<string, int> folders)
{
var ret = new List<string>();
try
{
string[] subDirs = Directory.GetDirectories(dir);
Expand All @@ -118,7 +118,7 @@ private void GetChildFolders(string dir, Dictionary<string, int> folders)
// Skip scanning directories with more than maxSubFolders... probably not useful and also very large folders can slow scanning/queries down considerably.
if (subDirs.Length <= maxSubFolders)
{
foreach (string subDir in Directory.GetDirectories(dir))
foreach (string subDir in subDirs)
{
Console.WriteLine(subDir);
if (!folders.ContainsKey(subDir))
Expand All @@ -130,7 +130,7 @@ private void GetChildFolders(string dir, Dictionary<string, int> folders)
}
else
{
Console.WriteLine("Skipped folder " + dir + ". Too many subdirs.");
Console.WriteLine(string.Format("Skipped folder {0}. More than {1} subdirs.", dir, maxSubFolders));
}
}
catch (System.Exception excpt)
Expand Down
7 changes: 7 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ Setting a weight to a negative number like that will cause it to be blacklisted
from all jump results. Use the `jumpstat -All` option to see negative weights
included in the jumpstat result set.

Jumpstat can also be used with the "scan" parameter (jumpstat -scan) to recursively
scan known directories and add their sub-directories into the database. This is a
quick way to teach Jump-Location about related directories without having to manually
cd'ing to each one individually. To keep the database size down to a reasonable
level, any directory with more than 50 child directories are ignored during
scanning. This is controlled by config key Jump.Location.Scan.MaxSubFolders in
Jump.Location.dll.config.

Why `Jump-Location`?
--------------------
Expand Down

0 comments on commit 349cdae

Please sign in to comment.