forked from tkellogg/Jump-Location
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I broke jumpstat into it's own Get-JumpStatus cmdlet to start maintaining separation of concerns. Once this was done, it was obvious to implement querying via Get-JumpStatus since it's already returning objects instead of changing directories. This is a great step towards scripting this a lot better than autojump was done. For one, it'll be easier to manipulate the DB (once we expose -Save). But moreso, this is a great step toward using jumpstat as input into other commands. I'd love to be able to do PS> explorer $(jumpstat ju) And have it jump right to my favorite project :)
- Loading branch information
Showing
5 changed files
with
49 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Management.Automation; | ||
|
||
namespace Jump.Location | ||
{ | ||
[Cmdlet("Get", "JumpStatus")] | ||
public class GetJumpStatusCommand : PSCmdlet | ||
{ | ||
private static readonly CommandController Controller = CommandController.DefaultInstance; | ||
|
||
[Parameter(ValueFromRemainingArguments = true)] | ||
public string[] Directory { get; set; } | ||
|
||
protected override void ProcessRecord() | ||
{ | ||
if (Directory == null || Directory.Length == 0) | ||
ProcessSearch(Controller.GetOrderedRecords()); | ||
else | ||
ProcessSearch(Controller.GetMatchesForSearchTerm(Directory)); | ||
} | ||
|
||
private void ProcessSearch(IEnumerable<IRecord> records) | ||
{ | ||
foreach (var record in records) | ||
WriteObject(record); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters