mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 07:05:47 +02:00
docs(std-rfc): use actual examples rather than doc comments (#15097)
# Description Update examples with attributes. # User-Facing Changes `std-rfc` commands now have examples. # Tests + Formatting N/A # After Submitting N/A
This commit is contained in:
@ -4,11 +4,9 @@
|
||||
# > Terminal multiplexers such as screen, tmux, zellij etc may interfere with this command
|
||||
|
||||
# Copy input to system clipboard
|
||||
#
|
||||
# # Example
|
||||
# ```nushell
|
||||
# >_ "Hello" | clip copy
|
||||
# ```
|
||||
@example "Copy a string to the clipboard" {
|
||||
"Hello" | clip copy
|
||||
}
|
||||
export def copy [
|
||||
--ansi (-a) # Copy ansi formatting
|
||||
]: any -> nothing {
|
||||
@ -35,12 +33,9 @@ export def copy [
|
||||
}
|
||||
|
||||
# Paste contents of system clipboard
|
||||
#
|
||||
# # Example
|
||||
# ```nushell
|
||||
# >_ clip paste
|
||||
# "Hello"
|
||||
# ```
|
||||
@example "Paste a string from the clipboard" {
|
||||
clip paste
|
||||
} --result "Hello"
|
||||
export def paste []: [nothing -> string] {
|
||||
try {
|
||||
term query $'(ansi osc)52;c;?(ansi st)' -p $'(ansi osc)52;c;' -t (ansi st)
|
||||
@ -56,9 +51,17 @@ export def paste []: [nothing -> string] {
|
||||
}
|
||||
|
||||
# Add a prefix to each line of the content to be copied
|
||||
#
|
||||
# # Example: Format output for Nushell doc
|
||||
# ls | clip prefix '# => ' | clip copy
|
||||
@example "Format output for Nushell doc" {
|
||||
[1 2 3] | clip prefix '# => '
|
||||
} --result "# => ╭───┬───╮
|
||||
# => │ 0 │ 1 │
|
||||
# => │ 1 │ 2 │
|
||||
# => │ 2 │ 3 │
|
||||
# => ╰───┴───╯
|
||||
# => "
|
||||
@example "Format output for Nushell doc and copy it" {
|
||||
ls | clip prefix '# => ' | clip copy
|
||||
}
|
||||
export def prefix [prefix: string]: any -> string {
|
||||
let input = $in | collect
|
||||
match ($input | describe -d | get type) {
|
||||
|
Reference in New Issue
Block a user