Skip to content
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

Update mandoc/markdown library to consider private visibility setting #552

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/bashly/concerns/completions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def completion_generator
end

def completion_flag_names
visible_flags.map(&:name) + public_flags.map(&:short)
visible_flags.map(&:name) + visible_flags.map(&:short)
end

def completion_allowed_args
Expand Down
8 changes: 4 additions & 4 deletions lib/bashly/libraries/render/mandoc/mandoc.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if extensible
end
>

if public_commands.any?
if visible_commands.any?
grouped_commands.each do |group, commands|
> {{ group.gsub(/:$/, '').upcase }}
> ==================================================
Expand Down Expand Up @@ -150,11 +150,11 @@ if dependencies.any?
end
end

if public_environment_variables.any?
if visible_environment_variables.any?
> ENVIRONMENT VARIABLES
> ==================================================
>
public_environment_variables.each do |environment_variable|
visible_environment_variables.each do |environment_variable|
> {{ environment_variable.name.upcase }}
> --------------------------------------------------
>
Expand Down Expand Up @@ -186,7 +186,7 @@ end

see_also = []
see_also << parents.first if parents.any?
see_also += public_commands.map { |x| x.full_name.to_hyphen } if public_commands.any?
see_also += visible_commands.map { |x| x.full_name.to_hyphen } if visible_commands.any?
see_also += x_mandoc_see_also if x_mandoc_see_also && x_mandoc_see_also.is_a?(Array)
see_also.map! do |item|
item.match(/(.+)(\(\d\))/) ? "**#{$1}**#{$2}" : "**#{item}**(1)"
Expand Down
4 changes: 2 additions & 2 deletions lib/bashly/libraries/render/markdown/markdown.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ end

# === Environment Variables

if public_environment_variables.any?
if visible_environment_variables.any?
> ## Environment Variables
>
public_environment_variables.each do |environment_variable|
visible_environment_variables.each do |environment_variable|
attributes = environment_variable.required || environment_variable.default

> #### *{{ environment_variable.name.upcase }}*
Expand Down
4 changes: 2 additions & 2 deletions lib/bashly/script/introspection/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ def default_command
def grouped_commands
result = {}

public_commands.each do |command|
visible_commands.each do |command|
result[command.group_string] ||= []
result[command.group_string] << command
next unless command.expose

command.public_commands.each do |subcommand|
command.visible_commands.each do |subcommand|
result[command.group_string] << subcommand
end
end
Expand Down
6 changes: 6 additions & 0 deletions lib/bashly/script/introspection/environment_variables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def validated_environment_variables
environment_variables.select(&:validate)
end

# Returns only public environment variables, or both public and private
# environment variables if Settings.private_reveal_key is set
def visible_environment_variables
Settings.private_reveal_key ? environment_variables : public_environment_variables
end

# Returns an array of all the environment_variables with a whitelist arg
def whitelisted_environment_variables
environment_variables.select(&:allowed)
Expand Down
2 changes: 1 addition & 1 deletion lib/bashly/views/argument/usage.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
> printf "{{ help.wrap(76).indent(4).sanitize_for_print }}\n"

if allowed
> printf " %s\n" "{{ strings[:allowed] % { values: allowed.join(', ') } }}\n"
> printf " %s\n" "{{ strings[:allowed] % { values: allowed.join(', ') } }}"
end

if default
Expand Down
13 changes: 12 additions & 1 deletion spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,21 @@ Some specs have tags for convenience:
- `:stable` - specs of features that rarely change
- `:noci` - specs that are disabled in CI

For example, to run only specs that are not :slow and not :stable, run:
## Useful respec commands


```bash
# smoke test; run only specs that are not :slow and not :stable
$ respec tagged ~stable ~slow

# test examples only
$ respec only examples

# test a specific example only
$ EXAMPLE=whitelist respec only examples

# test only specs that changed recently, and repeat on change
$ respec refactor # or respec r
```

## Notes about Example Tests
Expand Down
4 changes: 2 additions & 2 deletions spec/approvals/examples/command-private
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Usage:
cli --version | -v

Commands:
connect Connect to the metaverse
connect Connect to the metaverse

+ ./cli -h
cli - Sample application with private commands
Expand All @@ -25,7 +25,7 @@ Usage:
cli --version | -v

Commands:
connect Connect to the metaverse
connect Connect to the metaverse

Options:
--help, -h
Expand Down