Skip to content

Commit 5dc5258

Browse files
author
haghish
committed
2.0.4
updating an error in the documentation
1 parent 7bbe84a commit 5dc5258

3 files changed

Lines changed: 58 additions & 14 deletions

File tree

github.ado

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ where the subcommands can be:
2121
| _subcommand_ | _Description_ |
2222
|:-------------|:-------------------------------------------------------------------------|
2323
| install | followed by the _username/repository_, installs the specified repository |
24+
| require | followed by _username/repository_, examines the required version (see below) |
2425
| query | followed by _username/repository_, returns all released versions of that package |
2526
| check | followed by _username/repository_, evaluates whether the repository is installable |
2627
| uninstall | followed by _package name_, uninstalls a package |
2728
| search | followed by _keywords_, it searches the GitHub API for relevant packages or repositories |
2829
| findfile | followed by a _keyword_, it searches Stata packages for files that include the keyword |
2930
| list | lists the packages installed from GitHub and checkes if they have an update |
31+
| version | return the version of installed package or set a minimum required version |
3032
3133
Description
3234
-----------
@@ -60,7 +62,6 @@ searching for a keyword. The table shows the options accordingly:
6062
| stable | installs the latest stable release. otherwise the main branch is installed |
6163
| verson(_str_) | specifies a particular stable version (release tags) for the installation |
6264
63-
6465
### __github search__ options:
6566
6667
| _option_ | _Description_ |
@@ -98,11 +99,11 @@ install the latest development version of MarkDoc package
9899
99100
install the latest stable version of MarkDoc package
100101
101-
. github haghish/markdoc, stable
102+
. github install haghish/markdoc, stable
102103
103104
install MarkDoc version 3.8.1 from GitHub (older version)
104105
105-
. github haghish/markdoc, version("3.8.1")
106+
. github install haghish/markdoc, version("3.8.1")
106107
107108
Uninstall MarkDoc repository
108109
@@ -130,12 +131,21 @@ search for a script files with the name _dy_
130131
131132
. github findfile dy
132133
134+
### example of package management
135+
136+
list the installed packages
137+
138+
. github list
139+
140+
get the version of an installed packages, e.g. markdoc package
141+
142+
. github version markdoc
133143
134144
### examples of searching the popular packages
135145
136-
build the complete list of Stata packages on GiutHub
146+
search for Stata packages on GiutHub and save the search results in a data set
137147
138-
. github list stata, language(all) in(all) all save(archive) append
148+
. github search stata, language(Stata) save(archive)
139149
140150
Author
141151
------
@@ -159,13 +169,13 @@ PLEASE NOTE
159169
intended to be used internally
160170
*/
161171

162-
*cap prog drop github
172+
cap prog drop github
163173
prog define github
164174

165175
version 13
166176

167177
syntax anything, [stable Version(str) save(str) in(str) ///
168-
language(str) all NET package(str) ///
178+
language(str) all NET package(str) require(str) ///
169179
/// the options below are not documented yet ///
170180
force created(str) pushed(str) debug reference(str) ///
171181
duration(numlist max=1) perpage(numlist max=1) ///
@@ -192,7 +202,45 @@ prog define github
192202
// Version //CHANGE THIS TO INFO?
193203
// ---------
194204
if "`1'" == "version" {
195-
githubdb version, name(`anything')
205+
if missing("`require'") {
206+
githubdb version, name(`anything')
207+
}
208+
else {
209+
qui githubdb version, name(`anything')
210+
local currentversion `r(version)'
211+
if "`r(version)'" != "`require'" {
212+
tokenize "`r(version)'", parse(".")
213+
local currentversion `1'
214+
macro shift
215+
while !missing("`1'") {
216+
if "`1'" != "." local sub `sub'`1'
217+
macro shift
218+
}
219+
local currentversion `currentversion'.`sub'
220+
221+
tokenize "`require'", parse(".")
222+
local requiredversion `1'
223+
macro shift
224+
while !missing("`1'") {
225+
if "`1'" != "." local sub `sub'`1'
226+
macro shift
227+
}
228+
local requiredversion `requiredversion'.`sub'
229+
230+
// return error if rcall is old
231+
if `requiredversion' > `currentversion' {
232+
display as err "Version `requiredversion' or newer is " ///
233+
"required"
234+
err 198
235+
}
236+
else {
237+
di as txt "version `r(version)' meets version `require' requirement"
238+
}
239+
}
240+
else {
241+
di as txt "version `require' is currently installed"
242+
}
243+
}
196244
exit
197245
}
198246

github.sthlp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ install the latest development version of MarkDoc package
106106
{p 4 4 2}
107107
install the latest stable version of MarkDoc package
108108

109-
. github haghish/markdoc, stable
109+
. github install haghish/markdoc, stable
110110

111111
{p 4 4 2}
112112
install MarkDoc version 3.8.1 from GitHub (older version)
113113

114-
. github haghish/markdoc, version("3.8.1")
114+
. github install haghish/markdoc, version("3.8.1")
115115

116116
{p 4 4 2}
117117
Uninstall MarkDoc repository

make.do

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,3 @@ markdoc "vignette.do", export(tex) toc replace master ///
8080

8181

8282

83-
84-
85-
86-
å

0 commit comments

Comments
 (0)