We report a new method for electronic control of lasing regimes in lasers with compact all-fiber cavities. The method relies on incorporation of a waveguide electro-optic switch which plays the dual role as a variable output coupler and an intracavity intensity modulator. We explored this method in a laser comprised of a semiconductor optical amplifier and an all-fiber cavity. Nanosecond pulse lasing at 1540 nm was achieved in mode-locked, harmonically mode-locked, and cavity-dumping regimes at different repetition rates on kHz and MHz scales. This method is suitable for different fiber lasers and will allow even picosecond pulse lasing with an appropriately fast switch.