Skip to content

Commit

Permalink
add - doc - Added folders selector
Browse files Browse the repository at this point in the history
---

You can now use this selector to select a group of folders.

---

Type: add
Breaking: False
Doc Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Nov 28, 2023
1 parent c06f8d0 commit 5b43e09
Show file tree
Hide file tree
Showing 5 changed files with 614 additions and 1 deletion.
26 changes: 26 additions & 0 deletions public/Nitrocid/Files/Operations/Selection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,31 @@ public static string SelectFolder(string path)
string selected = FolderSelectorCli.SelectedFolder;
return selected;
}

/// <summary>
/// Opens the folder selector
/// </summary>
/// <returns>A list of selected folders, or an empty list if not selected</returns>
public static string[] SelectFolders() =>
SelectFolders(PathsManagement.HomePath);

/// <summary>
/// Opens the folder selector
/// </summary>
/// <param name="path">Target path to open</param>
/// <returns>A list of selected folders, or an empty list if not selected</returns>
public static string[] SelectFolders(string path)
{
var selector = new FoldersSelectorCli()
{
firstPanePath =
string.IsNullOrEmpty(path) ?
PathsManagement.HomePath :
FilesystemTools.NeutralizePath(path)
};
InteractiveTuiTools.OpenInteractiveTui(selector);
string[] selected = FoldersSelectorCli.SelectedFolders;
return selected;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Nitrocid KS Copyright (C) 2018-2023 Aptivi
//
// This file is part of Nitrocid KS
//
// Nitrocid KS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Nitrocid KS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using KS.ConsoleBase.Inputs.Styles.Infobox;
using KS.Files.Operations;
using KS.Languages;

namespace KS.Kernel.Debugging.Testing.Facades
{
internal class TestFoldersSelector : TestFacade
{
public override string TestName => Translate.DoTranslation("Tests the multiple folders selector");
public override TestSection TestSection => TestSection.Files;
public override void Run(params string[] args)
{
string[] selected = Selection.SelectFolders();
InfoBoxColor.WriteInfoBox(Translate.DoTranslation("You've selected") + $": {string.Join(", ", selected)}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ internal static class TestInteractive
{ "TestFileSelector", new TestFileSelector() },
{ "TestFilesSelector", new TestFilesSelector() },
{ "TestFolderSelector", new TestFolderSelector() },
{ "TestFoldersSelector", new TestFoldersSelector() },
};
internal static Dictionary<TestSection, string> sections = new()
{
Expand Down
Loading

0 comments on commit 5b43e09

Please sign in to comment.