
    (HJj
                         d Z ddlZddlZddlZddlZddlmZmZ  G d de      Z	d Z
d Zd Zdd	Zed
k(  r e        yy)z
CLI for the segments package.
    N)	TokenizerProfilec                       e Zd Zy)ParserErrorN)__name__
__module____qualname__     [/Users/ahmed/devFolder/claude-voice/.venv/lib/python3.12/site-packages/segments/__main__.pyr   r      s    r   r   c                     | j                   r8t        j                  | j                         j                         st	        d      t         t        | j                         t        |       | j                               y)z
    Tokenize a string (passed as argument or read from stdin)

    segments [--profile=PATH/TO/PROFILE] tokenize [STRING]
    z---profile must be a path for an existing file)profile)columnN)	r   pathlibPathexistsr   printr   _readmappingargss    r   tokenizer      sR     ||GLL6==?IJJ	
))DLL
)%+dll
KLr   c                 R    t        t        j                  t        |                    y)z{
    Create an orthography profile for a string (passed as argument or read from stdin)

    segments profile [STRING]
    N)r   r   	from_textr   r   s    r   r   r      s     
'

E$K
()r   c                     | j                   r| j                   d   nt        j                  j                         }t	        |t
              s|j                  | j                        }|j                         S )Nr   )	r   sysstdinread
isinstancestrdecodeencodingstrip)r   strings     r   r   r   $   sJ    !YYTYYq\CIINN,<Ffc"t}}-<<>r   c                    t         t        d}t        j                          t	        j
                  dd      }|j                  dd       |j                  dd	j                  |             |j                  d
t        j                         |j                  ddd       |j                  ddd        |j                  ddt        j                         | xs |j                         }|j                  dk(  rmt        |j                        rXt        |j                  d   |v r*||j                  d      j                   j#                         nd|j                  d    d       nT|j                  |vr0t        d       |j%                          t'        j(                  d       	  ||j                     |       t'        j(                  d       y # t*        $ rZ}t        |       t        ||j                     j                   j#                                t'        j(                  d       Y d }~td }~wt,        $ r*}t        |       t'        j(                  d       Y d }~d }~ww xY w)N)r   r   z4Main command line interface of the segments package.z@Use '%(prog)s help <cmd>' to get help about individual commands.)descriptionepilogz--verbosityzincrease output verbosity)helpcommandz | r   )nargsz
--encodingzinput encodingutf8)r(   defaultz	--profilezpath to an orthography profilez	--mappingz-column name in ortho profile to map graphemesr(   r   zInvalid command: ''zinvalid command@      )r   r   loggingbasicConfigargparseArgumentParseradd_argumentjoin	REMAINDERr   GRAPHEME_COL
parse_argsr)   lenr   r   __doc__r#   
print_helpr   exitr   	Exception)parsed_argscommandsparserr   es        r   mainrB   +   s   $9H$$JQSF ,GH
	

8(<=
h&8&89
+;VL
*JTXY
<$$  &
 -&++-D||v#dii. 	1) tyy|$,,2241CDIIaL>QR/S	U <<x'#$HHRL	"HT\\"4( HHQK  	!H(4<<(006689HHRLL 	!HHHQKK	s%   (G 	I'AH11I'= I""I'__main__)N)r:   r   r0   r   r2   segmentsr   r   r=   r   r   r   r   rB   r   r
   r   r   <module>rE      sQ        '	) 	M*$N zF r   