-
Notifications
You must be signed in to change notification settings - Fork 4
Add noman-help-format to specify argument ordering #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,45 @@ fi | |
(message name) | ||
name)) | ||
|
||
(defun make-npm () | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests look good, thanks for adding them 🙏 |
||
(let ((name (make-temp-file "npm"))) | ||
(f-write-text "#!/bin/bash | ||
if [[ \"$1\" == \"--help\" ]]; then | ||
echo ' | ||
npm <command> | ||
|
||
Usage: | ||
|
||
npm install install all the dependencies in your project | ||
npm install <foo> add the <foo> dependency to your project | ||
|
||
All commands: | ||
|
||
access, adduser, audit, bugs, cache, ci, completion, | ||
config, dedupe, deprecate, diff, dist-tag, docs, doctor, | ||
' | ||
fi | ||
|
||
if [[ \"$1\" == \"access\" ]]; then | ||
echo ' | ||
=NPM-ACCESS(1) NPM-ACCESS(1) | ||
|
||
NAME | ||
npm-access - Set access level on published packages | ||
|
||
See Also | ||
• libnpmaccess ⟨https://npm.im/libnpmaccess⟩ | ||
|
||
• npm help team | ||
|
||
• npm help publish | ||
' | ||
fi | ||
" 'utf-8-emacs name) | ||
(chmod name #o777) | ||
(message name) | ||
name)) | ||
|
||
(defun noman--test-setup () | ||
(setq noman-reuse-buffers nil) | ||
(kill-matching-buffers "\\*noman.*" nil t)) | ||
|
@@ -231,6 +270,35 @@ fi | |
"Create and run a particular image in a pod." | ||
(buffer-substring-no-properties (point-min) (point-max))))))) | ||
|
||
(ert-deftest noman-should-parse-npm () | ||
(noman--test-setup) | ||
(let* ((npm (make-npm)) | ||
(buffer (format "*noman %s*" npm))) | ||
(add-to-list 'noman-parsing-functions `(,npm . noman--make-npm-button)) | ||
(noman npm) | ||
(with-current-buffer (get-buffer buffer) | ||
(should (string-equal buffer (buffer-name))) | ||
(should (> (point-max) 0)) | ||
(should (search-forward "npm <command>" nil t 1)) | ||
(should (= (count-buttons) 14))))) | ||
|
||
(ert-deftest noman-should-parse-npm-subcommands () | ||
(noman--test-setup) | ||
(let* ((npm (make-npm)) | ||
(buffer (format "*noman %s*" npm)) | ||
(access-buffer (format "*noman %s access*" npm))) | ||
(add-to-list 'noman-parsing-functions `(,npm . noman--make-npm-button)) | ||
(noman npm) | ||
(with-current-buffer (get-buffer buffer) | ||
(noman-menu "access") | ||
(should (get-buffer access-buffer)) | ||
(with-current-buffer (get-buffer access-buffer) | ||
(should (string-equal access-buffer (buffer-name))) | ||
(should | ||
(search-forward | ||
"npm-access - Set access level on published packages" nil t 1)) | ||
(should (= (count-buttons) 2)))))) | ||
|
||
(ert-deftest noman-with-prefix-arg-allows-shell-built-ins () | ||
(let* ((type-buffer-name "*noman type*") | ||
(noman-shell-file-name "/bin/bash")) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do these functions need to take
&rest
arguments? It doesn't look like we need to pass any arguments to them any more, and they're not using the_
argument. Could they be parameterless?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you reevaluate
noman-parsing-functions
to make sure it was using the functions for npm/go? Those commands are buttonized when I run them locally, Ill try to add some tests.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, that was leftover from when I was experimenting... I was wondering if they should take a
context
argument - something that could hold parsing state.For example, if the parsing function might want to only buttonize matches in a certain part of the help output, eg. after seeing a line like "Additional commands:" or something. So the parsing function could have a state like
context.in_commands = true
.WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a good idea for the future, and I like your
subcommand-p
idea 👍However, if we're not using that argument just now, I think it would be better to make those functions parameterless. We can always introduce a parameter in the future when we need to (doing so would certainly make the
aws
parsing more accurate).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, I've just re-read your implementation, and I misunderstood it the first time round.
Yes, this is a good idea, let's keep it in 🙂