�
�Y�e � � � d dl Z d dlZd dlmZ d dlmZ d
d�Zdee fd�Z dee fd�Z
dedee fd �ZdS )� N)�Optional)�InvalidFeatureErrorc �F � t j � � }|� ddd�� � |� � � }|� dd�� � }|� ddd d
�� � |� dd
d d�� � |� ddd d�� � |� dddd�� � |� d�� � |� dd�� � }|� dddd�� � |� ddd d�� � |� d�� � |� dd�� � }|� dddd �� � |� ddd d�� � |� d�� � |� d!d"�� � }|� d!�� � |� d#d$�� � }|� d#�� � |� d%d&�� � }|� d%�� � |� d'd(�� � } | � d'�� � |� d)d*�� � }
|
� d#d+�� � |
� d)�� � |� d,d-�� � }|� d#d.�� � |� d,�� � |� d/d0�� � }|� d/�� � | r|� | � � S |� � � S )1z�
Constructs the command-line argument parser for cargo2rpm.
If arguments are passed to this function, they are parsed instead of parsing
actual command line arguments. This is useful for testing parser behaviour.
z-pz--pathz8Path to Cargo.toml (for current crate or workspace root))�help�
buildrequiresz*Print BuildRequires for the current crate.z-tz--with-check�
store_truezInclude dev-dependencies.)�actionr z-az--all-featureszEnable all featuresz-nz--no-default-featureszDisable default featuresz-fz-Fz
--featuresz*Comma-separated list of features to enable)r �requiresz;Print Requires for the current crate and the given feature.z --featurez-Name of the feature to generate Requires for.z-sz--subpackagez(Treat the argument as a subpackage name.�providesz;Print Provides for the current crate and the given feature.z-Name of the feature to generate Provides for.�namez$Print the name of the current crate.�versionz'Print the version of the current crate.zis-libzDPrint 1 if the current crate is a library target, otherwise print 0.zis-binzCPrint 1 if the current crate has binary targets, otherwise print 0.�
semver2rpmz7Convert SemVer version string to equivalent RPM format.zSemVer compliant version string�
rpm2semverz7Convert RPM version string to equivalent SemVer format.zRPM version stringzparse-vendor-manifestz:Parse vendor manifest generated by %%cargo_vendor_manifest)�argparse�ArgumentParser�add_argument�add_subparsers�
add_parser�set_defaults�
parse_args)
�args�parser�action_parsers�
action_brs�
action_req�action_prov�action_name�action_version�
action_is_lib�
action_is_bin�action_semver_to_rpm�action_rpm_to_semver�action_parse_vendor_manifests
�3/home/deca/Projects/rust/cargo2rpm/cargo2rpm/cli.py�get_argsr% s� � � �
$�
&�
&�F�
����h�-g��h�h�h��*�*�,�,�N��*�*�?�Am�*�n�n�J����D�.��Lg��h�h�h����D�"2�<�Nc��d�d�d����D�"9�,�Uo��p�p�p����D�$��;g��h�h�h����?��3�3�3��*�*�:�<y�*�z�z�J����D�$��:i��j�j�j����D�.��Lv��w�w�w����:��.�.�.� �+�+�J�=z�+�{�{�K����T�4��;j��k�k�k����T�>�,�Mw��x�x�x����J��/�/�/� �+�+�F�9_�+�`�`�K����F��+�+�+�#�.�.�y�?h�.�i�i�N����y��1�1�1�"�-�-�h� >D�-� E� E�M����h��/�/�/�"�-�-�h� >C�-� D� D�M����h��/�/�/�)�4�4�\� IB�4� C� C���%�%�i�6W�%�X�X�X��%�%�\�%�:�:�:�)�4�4�\� IB�4� C� C���%�%�i�6J�%�K�K�K��%�%�\�%�:�:�:�#1�#<�#<��&b� $=� $� $� � !�-�-�5L�-�M�M�M�� #�� � ��&�&�&�� � �"�"�"� �returnc �j � d� t j � � � D � � } d� | D � � S )z�
Read lines from standard input and filter out lines that look like paths
to `Cargo.toml` files. This is how RPM generators pass lists of files.
c �8 � h | ]}|� d � � ��S ��
��rstrip��.0�lines r$ � <setcomp>z2get_cargo_toml_paths_from_stdin.<locals>.<setcomp>J �$ � �A�A�A�4�T�[�[��
�
�A�A�Ar&