V, 18 17 16 bytes
1 byte saved thanks to @nmjcman101 for using another way of outputting nothing if the input is 0
é\é|ÀñÙá ñÒ-xÀ«D
Try it online!
Hexdump:
00000000: e95c e97c c0f1 d9e1 20f1 d22d 78c0 ab44 .\.|.... ..-x..D
Explanation (outdated)
We first have a loop to check if the argument is 0
. If so, the code below executes (|\
is written). Otherwise, nothing is written and the buffer is empty.
Àñ ñ " Argument times do:
é\é| " Write |\
h " Exit loop by creating a breaking error
Now that we got the top of the triangle, we need to create its body.
Àñ ñ " Argument times do:
Ù " Duplicate line, the cursor comes down
à<SPACE> " Append a space
Now we got one extra line at the bottom of the buffer. This has to be replaced with -
s.
Ó- " Replace every character with a -
x " Delete the extra '-'
This answer would be shorter if we could whatever we want for input 0
V, 14 13 bytes
é\é|ÀñÙá ñÒ-x
Try it online!