Wowpedia has a good example on that.
https://wow.gamepedia.com/Creating_a_slash_command
Depending on which frame it is you're looking to toggle on and off, it should be as simple as adding
if not frame:IsShown() then frame:Show() else frame:Hide() end in your handler function (replacing "frame" with the frame in question, of course.)
Not sure if :IsVisible() or :IsShown() would be preferable, you might have to experiment. Or someone probably knows. But since you'd be calling :Show() and :Hide() on that very same frame, :IsShown() should work fine.