Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F131645
cli.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
901 B
Referenced Files
None
Subscribers
None
cli.cpp
View Options
#include
<filesystem>
#include
<iostream>
#include
<optional>
#include
<regex>
#include
<string>
#include
"./file_scanner.hpp"
#include
"./sorter.hpp"
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
vector
<
std
::
string
>
args
;
args
.
reserve
(
argc
);
// Skip the first argument because that will be the programme name.
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
args
.
emplace_back
(
argv
[
i
]);
}
if
(
args
.
empty
())
{
std
::
cout
<<
"Missing required search term"
<<
std
::
endl
;
return
1
;
}
auto
base_dir
=
std
::
filesystem
::
current_path
();
std
::
string
search
=
args
.
at
(
0
);
auto
sorter
=
ivy
::
Sorter
(
search
);
auto
scanner
=
ivy
::
FileScanner
(
base_dir
);
std
::
regex
pattern
(
"(["
+
search
+
"])"
);
for
(
ivy
::
Match
const
&
match
:
sorter
.
sort
(
scanner
.
scan
()))
{
std
::
cout
<<
match
.
score
<<
" "
<<
std
::
regex_replace
(
match
.
content
,
pattern
,
"
\033
[1m$&
\033
[0m"
)
<<
std
::
endl
;
}
return
0
;
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Apr 6 2026, 6:09 PM (5 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15631
Default Alt Text
cli.cpp (901 B)
Attached To
Mode
R1 ivy.nvim
Attached
Detach File
Event Timeline
Log In to Comment