mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
61 lines
1.1 KiB
Julia
61 lines
1.1 KiB
Julia
#!/usr/bin/env julia
|
|
|
|
# From https://github.com/JoshCheek/language-sampler-for-fullpath/blob/b766dcdbd249ec63516f491390a75315e78cba95/julia/fullpath
|
|
help_screen = """
|
|
usage: fullpath *[relative-paths] [-c]
|
|
|
|
Prints the fullpath of the paths
|
|
If no paths are given as args, it will read them from stdin
|
|
|
|
If there is only one path, the trailing newline is omitted
|
|
|
|
The -c flag will copy the results into your pasteboard
|
|
"""
|
|
|
|
help = false
|
|
copy = false
|
|
dir = pwd()
|
|
paths = []
|
|
|
|
for arg = ARGS
|
|
if arg == "-h" || arg == "--help"
|
|
help = true
|
|
elseif arg == "-c" || arg == "--copy"
|
|
copy = true
|
|
elseif arg != ""
|
|
push!(paths, arg)
|
|
end
|
|
end
|
|
|
|
if help
|
|
print(help_screen)
|
|
exit()
|
|
end
|
|
|
|
function notempty(string)
|
|
return !isempty(string)
|
|
end
|
|
|
|
if length(paths) == 0
|
|
paths = filter(notempty, map(chomp, readlines()))
|
|
end
|
|
|
|
function print_paths(stream, paths)
|
|
if length(paths) == 1
|
|
path = paths[1]
|
|
print(stream, "$dir/$path")
|
|
else
|
|
for path = paths
|
|
println(stream, "$dir/$path")
|
|
end
|
|
end
|
|
end
|
|
|
|
if copy
|
|
read, write, process = readandwrite(`pbcopy`)
|
|
print_paths(write, paths)
|
|
close(write)
|
|
end
|
|
|
|
print_paths(STDOUT, paths)
|