Mercurial > hg > sonic-visualiser
comparison vext.sml @ 1708:975dee07ff5c vext
Update Vext
author | Chris Cannam |
---|---|
date | Wed, 07 Jun 2017 09:56:57 +0100 |
parents | d60b30ea9b80 |
children | e64981b88943 |
comparison
equal
deleted
inserted
replaced
1707:a4da817dc221 | 1708:975dee07ff5c |
---|---|
295 if n <= String.size str then str | 295 if n <= String.size str then str |
296 else pad_to n (str ^ " ") | 296 else pad_to n (str ^ " ") |
297 in | 297 in |
298 print ("\r " ^ | 298 print ("\r " ^ |
299 Vector.sub(tick_chars, !tick_cycle) ^ " " ^ | 299 Vector.sub(tick_chars, !tick_cycle) ^ " " ^ |
300 pad_to 50 name); | 300 pad_to 24 name); |
301 tick_cycle := (if !tick_cycle = n - 1 then 0 else 1 + !tick_cycle) | 301 tick_cycle := (if !tick_cycle = n - 1 then 0 else 1 + !tick_cycle) |
302 end | 302 end |
303 | 303 |
304 fun run_command context libname cmdlist redirect = | 304 fun run_command context libname cmdlist redirect = |
305 let open OS | 305 let open OS |
1555 val _ = print_header () | 1555 val _ = print_header () |
1556 in | 1556 in |
1557 app print_line lines; | 1557 app print_line lines; |
1558 lines | 1558 lines |
1559 end | 1559 end |
1560 | |
1561 fun return_code_for outcomes = | |
1562 foldl (fn ((_, result), acc) => | |
1563 case result of | |
1564 ERROR _ => OS.Process.failure | |
1565 | _ => acc) | |
1566 OS.Process.success | |
1567 outcomes | |
1560 | 1568 |
1561 fun status_of_project ({ context, libs } : project) = | 1569 fun status_of_project ({ context, libs } : project) = |
1562 ignore (act_and_print (AnyLibControl.status context) | 1570 return_code_for (act_and_print (AnyLibControl.status context) |
1563 print_status_header (print_status false) libs) | 1571 print_status_header (print_status false) |
1572 libs) | |
1564 | 1573 |
1565 fun review_project ({ context, libs } : project) = | 1574 fun review_project ({ context, libs } : project) = |
1566 ignore (act_and_print (AnyLibControl.review context) | 1575 return_code_for (act_and_print (AnyLibControl.review context) |
1567 print_status_header (print_status true) libs) | 1576 print_status_header (print_status true) |
1577 libs) | |
1568 | 1578 |
1569 fun update_project ({ context, libs } : project) = | 1579 fun update_project ({ context, libs } : project) = |
1570 let val outcomes = act_and_print | 1580 let val outcomes = act_and_print |
1571 (AnyLibControl.update context) | 1581 (AnyLibControl.update context) |
1572 print_outcome_header print_update_outcome libs | 1582 print_outcome_header print_update_outcome libs |
1573 val locks = List.concat | 1583 val locks = |
1574 (map (fn (libname, result) => | 1584 List.concat |
1575 case result of | 1585 (map (fn (libname, result) => |
1576 ERROR _ => [] | 1586 case result of |
1577 | OK id => [{ libname = libname, | 1587 ERROR _ => [] |
1578 id_or_tag = id | 1588 | OK id => [{ libname = libname, id_or_tag = id }]) |
1579 }] | 1589 outcomes) |
1580 ) | 1590 val return_code = return_code_for outcomes |
1581 outcomes) | |
1582 in | 1591 in |
1583 save_lock_file (#rootpath context) locks | 1592 if OS.Process.isSuccess return_code |
1593 then save_lock_file (#rootpath context) locks | |
1594 else (); | |
1595 return_code | |
1584 end | 1596 end |
1585 | 1597 |
1586 fun load_local_project use_locks = | 1598 fun load_local_project use_locks = |
1587 let val userconfig = load_userconfig () | 1599 let val userconfig = load_userconfig () |
1588 val rootpath = OS.FileSys.getDir () | 1600 val rootpath = OS.FileSys.getDir () |
1589 in | 1601 in |
1590 load_project userconfig rootpath use_locks | 1602 load_project userconfig rootpath use_locks |
1591 end | 1603 end |
1592 | 1604 |
1593 fun with_local_project use_locks f = | 1605 fun with_local_project use_locks f = |
1594 (f (load_local_project use_locks); print "\n") | 1606 let val return_code = f (load_local_project use_locks) |
1595 handle Fail err => print ("ERROR: " ^ err ^ "\n") | 1607 handle e => |
1596 | e => print ("Failed with exception: " ^ (exnMessage e) ^ "\n") | 1608 (print ("Failed with exception: " ^ |
1609 (exnMessage e) ^ "\n"); | |
1610 OS.Process.failure) | |
1611 val _ = print "\n"; | |
1612 in | |
1613 return_code | |
1614 end | |
1597 | 1615 |
1598 fun review () = with_local_project false review_project | 1616 fun review () = with_local_project false review_project |
1599 fun status () = with_local_project false status_of_project | 1617 fun status () = with_local_project false status_of_project |
1600 fun update () = with_local_project false update_project | 1618 fun update () = with_local_project false update_project |
1601 fun install () = with_local_project true update_project | 1619 fun install () = with_local_project true update_project |
1602 | 1620 |
1603 fun version () = | 1621 fun version () = |
1604 print ("v" ^ vext_version ^ "\n"); | 1622 (print ("v" ^ vext_version ^ "\n"); |
1623 OS.Process.success) | |
1605 | 1624 |
1606 fun usage () = | 1625 fun usage () = |
1607 (print "\nVext "; | 1626 (print "\nVext "; |
1608 version (); | 1627 version (); |
1609 print ("\nA simple manager for third-party source code dependencies.\n\n" | 1628 print ("\nA simple manager for third-party source code dependencies.\n\n" |
1612 ^ "where <command> is one of:\n\n" | 1631 ^ "where <command> is one of:\n\n" |
1613 ^ " review check configured libraries against their providers, and report\n" | 1632 ^ " review check configured libraries against their providers, and report\n" |
1614 ^ " status print quick report on local status only, without using network\n" | 1633 ^ " status print quick report on local status only, without using network\n" |
1615 ^ " install update configured libraries according to project specs and lock file\n" | 1634 ^ " install update configured libraries according to project specs and lock file\n" |
1616 ^ " update update configured libraries and lock file according to project specs\n" | 1635 ^ " update update configured libraries and lock file according to project specs\n" |
1617 ^ " version print the Vext version number and exit\n\n")) | 1636 ^ " version print the Vext version number and exit\n\n"); |
1637 OS.Process.failure) | |
1618 | 1638 |
1619 fun vext args = | 1639 fun vext args = |
1620 case args of | 1640 let val return_code = |
1621 ["review"] => review () | 1641 case args of |
1622 | ["status"] => status () | 1642 ["review"] => review () |
1623 | ["install"] => install () | 1643 | ["status"] => status () |
1624 | ["update"] => update () | 1644 | ["install"] => install () |
1625 | ["version"] => version () | 1645 | ["update"] => update () |
1626 | _ => usage () | 1646 | ["version"] => version () |
1647 | _ => usage () | |
1648 in | |
1649 OS.Process.exit return_code; | |
1650 () | |
1651 end | |
1627 | 1652 |
1628 fun main () = | 1653 fun main () = |
1629 vext (CommandLine.arguments ()) | 1654 vext (CommandLine.arguments ()) |