show hidden flag implemented
This commit is contained in:
parent
6f61a98ebc
commit
1b42869e3f
2 changed files with 14 additions and 9 deletions
|
@ -1,15 +1,14 @@
|
||||||
|
|
||||||
using Qdls;
|
using Qdls;
|
||||||
|
|
||||||
// collect args; no args becomes working directory
|
// collect args and consume flags
|
||||||
string[] arguments;
|
List<string> arguments = args.ToList();
|
||||||
if(args.Length == 0)
|
|
||||||
arguments = ["."];
|
|
||||||
else
|
|
||||||
arguments = args;
|
|
||||||
|
|
||||||
// flags
|
bool showHidden = Util.CheckFlag(arguments, "-a", "--all", "-A");
|
||||||
bool showHidden = false;
|
|
||||||
|
// default to "." if no target args
|
||||||
|
if(arguments.Count == 0)
|
||||||
|
arguments = ["."];
|
||||||
|
|
||||||
// run on targets
|
// run on targets
|
||||||
foreach(var arg in arguments) {
|
foreach(var arg in arguments) {
|
||||||
|
@ -21,6 +20,7 @@ foreach(var arg in arguments) {
|
||||||
|
|
||||||
// fetch children
|
// fetch children
|
||||||
var children = Directory.GetFileSystemEntries(arg);
|
var children = Directory.GetFileSystemEntries(arg);
|
||||||
|
// exclude hidden files where applicable
|
||||||
if(!showHidden) { children = children.Where(f => !Util.IsHidden(f)).ToArray(); }
|
if(!showHidden) { children = children.Where(f => !Util.IsHidden(f)).ToArray(); }
|
||||||
|
|
||||||
// state vars
|
// state vars
|
||||||
|
@ -37,7 +37,7 @@ foreach(var arg in arguments) {
|
||||||
foreach(var child in children) {
|
foreach(var child in children) {
|
||||||
var name = Path.GetFileName(child);
|
var name = Path.GetFileName(child);
|
||||||
|
|
||||||
// skip or format hidden files
|
// format hidden files
|
||||||
if(Util.IsHidden(child))
|
if(Util.IsHidden(child))
|
||||||
buffer += Format.Hidden;
|
buffer += Format.Hidden;
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,11 @@ public static class Util {
|
||||||
( File.GetAttributes(path) & FileAttributes.Hidden ) == FileAttributes.Hidden;
|
( File.GetAttributes(path) & FileAttributes.Hidden ) == FileAttributes.Hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool CheckFlag(List<String> args, params string[] forms) {
|
||||||
|
var found = args.RemoveAll(forms.Contains);
|
||||||
|
return found > 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Format {
|
public static class Format {
|
||||||
|
|
Loading…
Reference in a new issue