Skip to content

Commit cff3719

Browse files
authored
Cli ux improvements docs (#1328)
* updating documentation * split out publish tags * split out publish tags * split out publish tags * split out publish tags * split out publish tags
1 parent 06c7025 commit cff3719

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

src/nimble.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,10 +2381,10 @@ proc doAction(options: var Options) =
23812381
init(options)
23822382
of actionPublish:
23832383
var pkgInfo = getPkgInfo(getCurrentDir(), options)
2384-
if options.action.publishAction == "tags":
2385-
publishTags(pkgInfo, options)
2386-
else:
2387-
publish(pkgInfo, options)
2384+
publish(pkgInfo, options)
2385+
of actionPublishTags:
2386+
var pkgInfo = getPkgInfo(getCurrentDir(), options)
2387+
publishTags(pkgInfo, options)
23882388
of actionDump:
23892389
dump(options)
23902390
of actionTasks:

src/nimblepkg/options.nim

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ type
7070
actionInstall, actionSearch, actionList, actionBuild, actionPath,
7171
actionUninstall, actionCompile, actionDoc, actionCustom, actionTasks,
7272
actionDevelop, actionCheck, actionLock, actionRun, actionSync, actionSetup,
73-
actionClean, actionDeps, actionShellEnv, actionShell, actionAdd, actionManual
73+
actionClean, actionDeps, actionShellEnv, actionShell, actionAdd, actionManual,
74+
actionPublishTags
7475

7576
DevelopActionType* = enum
7677
datAdd, datRemoveByPath, datRemoveByName, datInclude, datExclude
@@ -124,6 +125,8 @@ type
124125
depsAction*: string
125126
of actionPublish:
126127
publishAction*: string
128+
of actionPublishTags:
129+
onlyListTags*: bool
127130
of actionShellEnv, actionShell:
128131
discard
129132

@@ -177,6 +180,10 @@ Commands:
177180
publish Publishes a package on nim-lang/packages.
178181
The current working directory needs to be the
179182
top level directory of the Nimble package.
183+
publishTags Finds and publishes new tags based on the
184+
commits where a package's Nimble file changed.
185+
[-l, --listOnly] Only list the tags and versions which are found without
186+
actually performing tag or publishing them.
180187
uninstall [pkgname, ...] Uninstalls a list of packages.
181188
[-i, --inclDeps] Uninstalls package and dependent package(s).
182189
build [opts, ...] [bin] Builds a package. Passes options to the Nim
@@ -216,9 +223,11 @@ Commands:
216223
[--ini, --json] Selects the output format (the default is --ini).
217224
lock Generates or updates a package lock file.
218225
upgrade [pkgname, ...] Upgrades a list of packages in the lock file.
219-
deps Outputs dependency tree
226+
deps Outputs dependencies for current package.
227+
[--tree] Outputs dependency tree.
228+
[--inverted] Outputs inverted (reversed) dependency tree.
220229
[--format type] Specify the output format. Json is the only supported
221-
format
230+
format. Only some commands support it.
222231
sync Synchronizes develop mode dependencies with
223232
the content of the lock file.
224233
[-l, --listOnly] Only lists the packages which are not synced
@@ -329,6 +338,8 @@ proc parseActionType*(action: string): ActionType =
329338
result = actionUninstall
330339
of "publish":
331340
result = actionPublish
341+
of "publishtags":
342+
result = actionPublishTags
332343
of "upgrade":
333344
result = actionUpgrade
334345
of "tasks":
@@ -762,6 +773,12 @@ proc parseFlag*(flag, val: string, result: var Options, kind = cmdLongOption) =
762773
result.action.publishAction = "tags"
763774
else:
764775
wasFlagHandled = false
776+
of actionPublishTags:
777+
case f
778+
of "l", "listonly":
779+
result.action.onlyListTags = true
780+
else:
781+
wasFlagHandled = false
765782
of actionDeps:
766783
case f
767784
of "format":

src/nimblepkg/publish.nim

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ proc createTag*(tag: string, commit: Sha1Hash, message, repoDir, nimbleFile: str
282282
of DownloadMethod.hg:
283283
assert false, "hg not supported"
284284

285-
proc findVersions(commits: seq[(Sha1Hash, string)], projdir, nimbleFile: string, downloadMethod: DownloadMethod) =
285+
proc findVersions(commits: seq[(Sha1Hash, string)], projdir, nimbleFile: string, downloadMethod: DownloadMethod, options: Options) =
286286
## parse the versions
287287
var
288288
versions: HashSet[Version]
@@ -305,23 +305,20 @@ proc findVersions(commits: seq[(Sha1Hash, string)], projdir, nimbleFile: string,
305305
if version notin versions:
306306
versions.incl(version)
307307
if version in existingTags:
308-
displayInfo(&"Found existing tag for version {version}", MediumPriority)
308+
displayInfo(&"Found existing tag for version {version} at commit {commit}", HighPriority)
309309
else:
310-
displayInfo(&"Found new version {version} at {commit}", MediumPriority)
311-
let res = createTag(&"v{version}", commit, message, projdir, nimbleFile, downloadMethod)
312-
if not res:
313-
displayError(&"Unable to create tag {version}")
310+
displayInfo(&"Found new version {version} at {commit}", HighPriority)
311+
if not options.action.onlyListTags:
312+
displayWarning(&"Creating tag for new version {version} at {commit}", HighPriority)
313+
let res = createTag(&"v{version}", commit, message, projdir, nimbleFile, downloadMethod)
314+
if not res:
315+
displayError(&"Unable to create tag {version}", HighPriority)
314316

315-
proc publishTags*(p: PackageInfo, o: Options) =
316-
discard
317-
echo "publishTags:myPath: ", $p.myPath
318-
echo "publishTags:basic: ", $p.basicInfo
319-
# echo "publishTags: ", $p
317+
proc publishTags*(p: PackageInfo, options: Options) =
318+
displayInfo(&"Searcing for new tags for {$p.basicInfo.name} @{$p.basicInfo.version}", HighPriority)
320319
let (projdir, file, ext) = p.myPath.splitFile()
321320
let nimblefile = file & ext
322321
let dlmethod = p.metadata.downloadMethod
323322
let commits = vcsFindCommits(projdir, nimbleFile, dlmethod)
324-
echo "publishTags:commits: ", $commits.len()
325323

326-
findVersions(commits, projdir, nimbleFile, dlmethod)
327-
echo ""
324+
findVersions(commits, projdir, nimbleFile, dlmethod, options)

0 commit comments

Comments
 (0)