Index: tools/sxcat.adb ================================================================== --- tools/sxcat.adb +++ tools/sxcat.adb @@ -101,18 +101,20 @@ Unix_Newline, UTF_8, Verbatim, Width, Upper_Hex, - Lower_Hex); + Lower_Hex, + Atom_List); type Action is (Error, Print_Help, Run, Run_Base64, Print_Atom, + Print_Atom_List, Print_Config); end Options; package Getopt is new Natools.Getopt_Long (Options.Id); @@ -249,10 +251,12 @@ ("width", 'w', Required_Argument, Options.Width); Result.Add_Option ("upper-hex", 'X', No_Argument, Options.Upper_Hex); Result.Add_Option ("lower-hex", 'x', No_Argument, Options.Lower_Hex); + Result.Add_Option + ("atom-list", No_Argument, Options.Atom_List); return Result; end Getopt_Config; overriding procedure Option @@ -268,10 +272,15 @@ when Options.Atom => if Handler.Action in Options.Run .. Options.Print_Config then Handler.Action := Options.Print_Atom; end if; + + when Options.Atom_List => + if Handler.Action in Options.Run .. Options.Print_Config then + Handler.Action := Options.Print_Atom_List; + end if; when Options.Base64_Atom => Param.Quoted := SE.Printers.Pretty.No_Quoted; Param.Fallback := SE.Printers.Pretty.Base64; @@ -532,10 +541,11 @@ end Parse_Separator; Printer_Direct : SE.Printers.Pretty.Stream_Printer (Output_Stream); Base64_Output : aliased Base64_Stream (Output_Stream); Printer_Base64 : SE.Printers.Pretty.Stream_Printer (Base64_Output'Access); + First_Atom_In_List : Boolean := True; procedure Process (Handler : in Callback'Class; Input : access Ada.Streams.Root_Stream_Type'Class) is begin @@ -553,10 +563,19 @@ end if; Printer_Base64.Set_Parameters (Param); Process (Printer_Base64, Input, True); when Options.Print_Atom => + Printer_Direct.Set_Parameters (Param); + Process (Printer_Direct, Input, False); + + when Options.Print_Atom_List => + if First_Atom_In_List then + Printer_Direct.Open_List; + First_Atom_In_List := False; + end if; + Printer_Direct.Set_Parameters (Param); Process (Printer_Direct, Input, False); end case; end Process; @@ -628,10 +647,15 @@ when Options.Atom => New_Line (Output); Put_Line (Output, Indent & Indent & "Treat intputs as individual atoms"); + when Options.Atom_List => + New_Line (Output); + Put_Line (Output, Indent & Indent + & "Treat intputs as a list of individual atoms"); + when Options.Base64_Expr => New_Line (Output); Put_Line (Output, Indent & Indent & "Output the expression in base-64 encoding"); @@ -855,14 +879,19 @@ when Options.Print_Help => Print_Help (Opt_Config, Ada.Text_IO.Current_Output); when Options.Print_Config => Printer_Direct.Set_Parameters (Param); SE.Printers.Pretty.Config.Print (Printer_Direct, To_Print); - when Options.Run .. Options.Print_Atom => + when Options.Run .. Options.Print_Atom_List => if Handler.Arg_Count = 0 then Handler.Argument ("-"); end if; if Options."=" (Handler.Action, Options.Run_Base64) then Close (Base64_Output); + elsif Options."=" (Handler.Action, Options.Print_Atom_List) then + if First_Atom_In_List then + Printer_Direct.Open_List; + end if; + Printer_Direct.Close_List; end if; end case; end Sxcat;