# formats.text.TmuxText.as_flag

- **Module:** formats.text.TmuxText
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/formats/text.rs#L111
- **Page:** https://libtmux.org/en/rs/latest/reference/formats-text-tmuxtext-as_flag/

```
formats.text.TmuxText.as_flag(self) -> Option<bool>
```

Interpret these bytes as a tmux flag.

tmux writes flags as `on` and `off`, and accepts `yes` and `no` for
some. Anything else returns `None` rather than guessing, because an
option holding arbitrary text is not a flag.

## Example

```rust
use libtmux::TmuxText;

assert_eq!(TmuxText::from("on").as_flag(), Some(true));
assert_eq!(TmuxText::from("off").as_flag(), Some(false));
assert_eq!(TmuxText::from("sometimes").as_flag(), None);
```
