forked from tempestphp/highlight
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTerminalFilePathPattern.php
More file actions
29 lines (23 loc) · 884 Bytes
/
TerminalFilePathPattern.php
File metadata and controls
29 lines (23 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
declare(strict_types=1);
namespace Tempest\Highlight\Languages\Terminal\Patterns;
use Tempest\Highlight\IsPattern;
use Tempest\Highlight\Pattern;
use Tempest\Highlight\PatternTest;
use Tempest\Highlight\Tokens\TokenTypeEnum;
#[PatternTest(input: 'start app.js --log', output: 'app.js')]
#[PatternTest(input: '--log /var/log/my-app.log', output: '/var/log/my-app.log')]
#[PatternTest(input: 'add .husky/pre-commit foo', output: '.husky/pre-commit')]
#[PatternTest(input: 'install hashicorp/tap/terraform', output: 'hashicorp/tap/terraform')]
final readonly class TerminalFilePathPattern implements Pattern
{
use IsPattern;
public function getPattern(): string
{
return '/(?<match>\.?\/?[\w.-]+(?:\/[\w.\/-]+)+|[\w][\w-]*\.[a-zA-Z]{1,10}\b)/';
}
public function getTokenType(): TokenTypeEnum
{
return TokenTypeEnum::PROPERTY;
}
}