コード例 #1
0
        public bool Execute(IEnumerable <string> arguments, IOptionParser options)
        {
            var search = string.Join(" ", arguments);

            _consoleWriter.WriteLine($"Find Files: {search}");

            var files = _file.Search(search).ToList();

            if (files.Any())
            {
                var table = FileTable();
                foreach (var file in files)
                {
                    if (options.HasOption <OpenOption>())
                    {
                        FileHelper.OpenWithAssociatedProgram(file.Path);
                    }

                    table.Append(file.Hash.Result.ShortHash(), file.CreatedAt, file.Size.HumanSize(), file.Path);
                }
                table.WriteTo(_consoleWriter);
            }
            else
            {
                _consoleWriter.WriteLine("No files found for your search query...");
            }

            return(true);
        }
コード例 #2
0
        private bool PrintTagVariables(IOptionParser options)
        {
            var autoTagHandler = _container.Resolve <IAutoTagHandler>();

            _console.Writer.WriteLine("Possible Tag Variables:");
            _console.Writer.WriteLine();
            foreach (var tag in autoTagHandler.AutoTags.OrderBy(tag => tag.AutoTagKey))
            {
                _console.Writer.WriteLine($"* {tag.HumanReadableAutoTagsKey}");
                if (options.HasOption <VerboseOption>())
                {
                    _console.Writer.WriteLine($"=>  {tag.Description}");
                    _console.Writer.WriteLine();
                }
            }

            return(true);
        }
コード例 #3
0
        public async Task ExecuteAsync(IEnumerable <string> lazyArguments, IOptionParser options)
        {
            var arguments = lazyArguments.ToList();
            var tags      = arguments.Where(a => a.IsTag()).ToList();
            var files     = arguments.Where(IsFile);

            foreach (var file in _filePathExtractor.FromFilePatterns(files, options.HasOption <RecursiveOption>()).Select(FileFromPath))
            {
                if (tags.Count == 0)
                {
                    _file.Store(file);
                }
                else
                {
                    await TagFile(tags, file);
                }
            }
        }
コード例 #4
0
        public bool Execute(IEnumerable <string> arguments, IOptionParser options)
        {
            var tags  = arguments.Where(a => a.IsTag());
            var files = arguments.Where(IsFile);

            foreach (var file in _filePathExtractor.FromFilePatterns(files, options.HasOption <RecursiveOption>()).Select(FileFromPath))
            {
                foreach (var tag in tags.Select(_tagParser.Parse))
                {
                    if (tag != null)
                    {
                        _logger.LogInformation($"File {file.Path} tagged with {tag.Name}");
                        file.Untag(tag);
                    }
                }
            }

            return(true);
        }
コード例 #5
0
        public bool Execute(IEnumerable <string> arguments, IOptionParser options)
        {
            foreach (var filePath in _filePathExtractor.FromFilePatterns(arguments, options.HasOption <RecursiveOption>()))
            {
                _consoleWriter.WriteLine();
                _consoleWriter.WriteLine($"File: {filePath}");

                var file = _newFile();

                file.LoadByPathFromDb(filePath);
                if (file.Hash == null)
                {
                    _consoleWriter.WriteLine("File not in index!");
                }
                else
                {
                    _consoleWriter.WriteLine($"CreatedAt (oldest): {file.CreatedAt}");
                    _consoleWriter.WriteLine($"File Size: {file.Size}");
                    _consoleWriter.WriteLine($"File Hash: {file.Hash.Result}");

                    foreach (var tag in file.GetTags().Result)
                    {
                        _consoleWriter.WriteLine($"Tag: {tag.FullName}");
                    }

                    foreach (var name in file.GetNames().Result)
                    {
                        _consoleWriter.WriteLine($"Name: {name}");
                    }

                    foreach (var path in file.GetPaths().Result)
                    {
                        _consoleWriter.WriteLine($"Path: {path}");
                    }
                }
            }

            return(true);
        }