Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions core/Command/SystemTag/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
use OC\Core\Command\Base;
use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTagObjectMapper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class ListCommand extends Base {
public function __construct(
protected ISystemTagManager $systemTagManager,
protected ISystemTagObjectMapper $systemTagObjectMapper,
) {
parent::__construct();
}
Expand All @@ -34,6 +36,12 @@ protected function configure() {
null,
InputOption::VALUE_OPTIONAL,
'optional search pattern for the tag name (infix)'
)
->addOption(
'notUsedByFiles',
null,
InputOption::VALUE_OPTIONAL,
'not used by files (1,0)'
);
parent::configure();
}
Expand All @@ -44,6 +52,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$input->getOption('nameSearchPattern')
);

if ($input->getOption('notUsedByFiles') == 1) {
$result = [];
foreach ($tags as $tag) {
$objId = $this->systemTagObjectMapper->getObjectIdsForTags((string)$tag->getId(), 'files', 1);
if ($objId == null) {
$result[] = $tag;
}
}
$tags = $result;
}

$this->writeArrayInOutputFormat($input, $output, $this->formatTags($tags));
return 0;
}
Expand Down