Skip to content

Commit cee4244

Browse files
committed
transferred cd and cdpkg commands into repository
1 parent e621aae commit cee4244

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

src/args.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is part of VerTeX.jl. It is licensed under the MIT license
33
# Copyright (C) 2019 Michael Reed
44

5-
import ..load, ..save, ..checkmerge, ..readtex, ..writetex, ..tex2dict, ..save, ..article, ..manifest, ..readmanifest, ..getdepot, ..readdictionary, ..dictionary, ..preview_vertex, ..searchvtx
5+
import ..load, ..save, ..checkmerge, ..readtex, ..writetex, ..tex2dict, ..save, ..article, ..manifest, ..readmanifest, ..getdepot, ..readdictionary, ..dictionary, ..preview_vertex, ..searchvtx, ..cdpkg
66

77
using TerminalMenus
88

src/cmd.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,30 @@ select file to preview from repo
112112
113113
search for results
114114
"""
115+
],[ :kind => CMD_CD,
116+
:name => "cd",
117+
:handler => do_cd!,
118+
:arg_count => 0 => 1,
119+
:arg_parser => identity,
120+
:description => "change directory",
121+
:help => md"""
122+
123+
cd [repo]
124+
125+
change directory
126+
"""
127+
],[ :kind => CMD_CDPKG,
128+
:name => "cdpkg",
129+
:handler => do_cdpkg!,
130+
:arg_count => 1 => 1,
131+
:arg_parser => identity,
132+
:description => "change directory to package source",
133+
:help => md"""
134+
135+
cdpkg repo
136+
137+
change directory to package source
138+
"""
115139
],
116140
], #package
117141
] #command_declarations

src/depot.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
# This file is part of VerTeX.jl. It is licensed under the MIT license
33
# Copyright (C) 2018 Michael Reed
44

5+
export cdpkg, @cdpkg
6+
7+
cdpkg(pkg) = cd(dirname(Base.find_package(string(pkg))))
8+
9+
macro cdpkg(pkg)
10+
cdpkg(pkg)
11+
return nothing
12+
end
13+
514
repos = Dict("julia"=>"~/.julia/vtx/")
615

716
manifest = Dict("julia"=>Dict())

src/repl.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const OptionDeclaration = Vector{Pair{Symbol,Any}}
2929
# Commands #
3030
#----------#
3131
@enum(CommandKind, CMD_HELP, CMD_VIM, CMD_PDF, CMD_STATUS, CMD_DICT,
32-
CMD_RANGER, CMD_PREVIEW, CMD_SEARCH)
32+
CMD_RANGER, CMD_PREVIEW, CMD_SEARCH, CMD_CD, CMD_CDPKG)
3333
#=@enum(CommandKind, CMD_HELP, CMD_RM, CMD_ADD, CMD_DEVELOP, CMD_UP,
3434
CMD_STATUS, CMD_TEST, CMD_GC, CMD_BUILD, CMD_PIN,
3535
CMD_FREE, CMD_GENERATE, CMD_RESOLVE, CMD_PRECOMPILE,
@@ -132,6 +132,19 @@ do_preview!(a,b) = preview_vertex(load(raw(a)...))
132132

133133
do_search!(a,b) = preview_vertex.(searchvtx([:search],raw(a)))
134134

135+
function do_cd!(a,b)
136+
if length(a)<1
137+
dir = joinpath(homedir(),".julia","config","cd")
138+
run(`ranger $(pwd()) --choosedir=$dir`)
139+
cd(read(`cat $dir`,String))
140+
else
141+
cd(joinpath(expanduser(getdepot()[a[1].raw])))
142+
end
143+
println(pwd())
144+
end
145+
146+
do_cdpkg!(a,b) = (cdpkg(a[1].raw); println(pwd()))
147+
135148
######################
136149
# REPL mode creation #
137150
######################

0 commit comments

Comments
 (0)